Skip to content

RF-39249 Add AI Test Generation Command#500

Open
sebaherrera07 wants to merge 2 commits intomasterfrom
RF-39249-support-ai-test-generation
Open

RF-39249 Add AI Test Generation Command#500
sebaherrera07 wants to merge 2 commits intomasterfrom
RF-39249-support-ai-test-generation

Conversation

@sebaherrera07
Copy link
Member

@sebaherrera07 sebaherrera07 commented Feb 3, 2026

Tested manually ☑️

Introduces AI-powered test generation to the Rainforest CLI, allowing users to create tests using natural language prompts.

New Commands

rainforest generate - Generate a new test from a natural language prompt

rainforest generate "Log in with valid credentials" --start-uri /login

Key Features

  • Natural language prompt input
  • Support for --start-uri or --url (mutually exclusive)
  • Optional --title and --environment-id flags
  • Login via --credentials (free-form string passed to AI) or --login-snippet-id (mutually exclusive)
  • Single platform support via --platform (validated with [a-z0-9_] pattern; omit to use backend default)

Implementation Highlights

  • Added CreateTestWithAI() API method
  • Comprehensive validation (mutual exclusivity, required fields, platform format)
  • Single browser enforcement (API limitation)
  • Backend handles defaults for platform and title when not specified

Version: 3.8.0

@marvin-rfbot
Copy link

marvin-rfbot bot commented Feb 3, 2026

This comment was marked as outdated.

This comment was marked as outdated.

@sebaherrera07 sebaherrera07 changed the title RF-39249 Add generate command for AI test generation [WIP] RF-39249 Add generate command for AI test generation Feb 3, 2026
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch 2 times, most recently from 7119044 to 7fa7b22 Compare February 3, 2026 18:26
@sebaherrera07 sebaherrera07 requested a review from Copilot February 3, 2026 18:26
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch from 7fa7b22 to 4be863d Compare February 3, 2026 18:29

This comment was marked as outdated.

@sebaherrera07 sebaherrera07 changed the title [WIP] RF-39249 Add generate command for AI test generation [WIP] RF-39249 Add AI Test Generation and Regeneration Commands Feb 3, 2026
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch from 4be863d to c179fac Compare February 3, 2026 21:46
@sebaherrera07 sebaherrera07 requested a review from Copilot February 3, 2026 21:48

This comment was marked as outdated.

This comment was marked as outdated.

@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch 2 times, most recently from 22f31f0 to 74bf734 Compare February 4, 2026 17:38
@sebaherrera07 sebaherrera07 changed the title [WIP] RF-39249 Add AI Test Generation and Regeneration Commands [WIP] RF-39249 Add AI Test Generation Command Feb 4, 2026
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch 2 times, most recently from b696760 to 26f2e5f Compare February 4, 2026 18:06
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch 2 times, most recently from ef9679b to efead42 Compare February 10, 2026 18:29
@sebaherrera07 sebaherrera07 changed the title [WIP] RF-39249 Add AI Test Generation Command RF-39249 Add AI Test Generation Command Feb 10, 2026
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch from efead42 to 8e41eb9 Compare February 11, 2026 17:52
@sebaherrera07
Copy link
Member Author

/reviewme @ubergeek42

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@ubergeek42 ubergeek42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have a bunch of questions/concerns about RFML/download/export, because I don't think that's a thing for automated tests.

README.md Outdated
Comment on lines 218 to 222
Download the generated test as an RFML file after creation.

```bash
rainforest generate "Search for a product" --start-uri /search --download
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this makes any sense. RFML is for plain english tests, which test generation doesn't produce.

},
cli.StringFlag{
Name: "credentials",
Usage: "Credentials information to pass to the AI for test generation. Mutually exclusive with --login-snippet-id.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This help text seems like it could be better. What is the expected format for this? Is it just an opaque string that gets passed into some AI model under the hood, so you can write whatever you want here? Or do they need to be username: whatever; password: something_else?

Comment on lines 402 to 405
cli.BoolFlag{
Name: "download, d",
Usage: "Download the generated test as an RFML file after creation.",
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, I don't think this makes sense.

tests.go Outdated
Comment on lines 315 to 316
if len(browserNames) == 0 {
browserName = "windows11_chrome"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the backend require us to pass a value for platform? If we leave it blank/unset/null in the api request, will it default to something sane on the backend?

I'd prefer not to set a default here if the backend will already do so, as it makes changing the default later on more annoying (two places instead of one)

tests.go Outdated
// parseAndValidateBrowser parses the platform flag for AI test generation.
// Returns the browsers array with a single browser name.
func parseAndValidateBrowser(c cliContext) ([]string, error) {
browserNames := c.StringSlice("platform")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little curious why we're doing any processing on this to turn it into a list, just to say "hey, we don't support this being a list". Shouldn't it just be that we only accept a single platform, and let the backend validate it as a valid platform or not. And if we want to get fancier, just say that anything that contains characters other than [a-z0-9_] isn't valid.

tests.go Outdated

title := c.String("title")
if title == "" {
// Use first 50 characters (runes) of prompt as default title
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope, but I wonder if we should just send in an empty title, and have the backend generate one based on what actually got created. Similar to how chatgpt/gemini/etc give a name to your chat after your initial message that "summarizes" what it's about.

But similar to the above, I don't like setting a default/passing it in if we can avoid it and let the backend choose a sane default. I don't know what the backend behavior currently is, so maybe this is fine for now.

tests.go Outdated
Comment on lines 401 to 403
log.Printf("Successfully created test #%d: %s", response.TestID, response.Title)
log.Printf("RFML ID: %s", response.RFMLID)
log.Printf("State: %s", response.State)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this needs some note about how the test is technically created, but is still processing/generating? And RFMLID should go away.

@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch from 8e41eb9 to ce865c0 Compare February 12, 2026 18:39
Add support for generating tests using AI through the CLI. The new
`generate` command (with `gen` and `ai` aliases) accepts a natural
language prompt and creates a test via the Rainforest API.

Features:
- Generate tests from natural language prompts
- Support for --start-uri or --url to specify the starting point
- Optional --title flag for custom test name
- Optional --environment-id flag for test environment
- Support for authentication via --credentials or --login-snippet-id
  (mutually exclusive); credentials is a free-form string passed to
  the AI model
- Platform selection with --platform (single value, validated with
  [a-z0-9_] pattern, backend provides default if omitted)
- Comprehensive validation and error handling

Example usage:
  rainforest generate "Log in with valid credentials" --start-uri /login
  rainforest generate "Add item to cart" --url https://example.com
Update version constant and add CHANGELOG entry for the new
`generate` command feature.
@sebaherrera07 sebaherrera07 force-pushed the RF-39249-support-ai-test-generation branch from ce865c0 to 8098c2d Compare February 12, 2026 18:47
@sebaherrera07
Copy link
Member Author

/reviewme @ubergeek42

@marvin-rfbot marvin-rfbot bot requested a review from ubergeek42 February 12, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants