Building robust test coverage for your APIs can take time. With GenAI Test Creation, you can accelerate this process.
This article explains how to create an API test with GenAI:
- Define the intent of the test
- Add information about the API under test
- Launch the API Test Editor
- Build out the test
Early access
During the early access period, GenAI Test Creation is available for all users to try out at no additional cost.
- Most customers: this feature is already available on the test creation page.
- Customers who opted out of AI features: if you want to try GenAI Test Creation, please reach out to your customer success manager.
- Trial users: request a demo to get access.
For transparency, mabl currently intends to include GenAI Test Creation as part of the Advanced AI add-on at general availability. Please note that this approach is subject to change.
Define the intent of the test
When you create a new API test, add a description of what you want the test to accomplish. mabl’s AI will generate test steps to carry out this intent.
Providing an intent for a test
If you have specific endpoints you want to test, or a specific sequence of calls you expect from your API test, you can provide additional details in the test intent to yield more successful results.
For example, you could augment the test intent “Verify full CRUD on mabl mailbox endpoints” with the following details:
“Verify interactions with permanent mabl mailboxes:
- Create: Create a permanent mailbox with name ‘API Test generated mailbox’
- Read: Get the newly created mailbox and validate its properties are as expected
- Update: Test updating the mailbox’s metadata, such as name and description
- Enable/disable: Test enabling or disabling the mailbox works as expected
- Delete: Clean up at the end of the test by deleting the mailbox”
When you add a test intent, a new API specification section appears on the test creation form. Use this section to add information about the API under test.
Add information about the API under test
To generate API test steps, mabl needs to know what API endpoints are available to interact with and how to interact with them. In the API specification section, upload files and/or provide an API description.
Upload a file
For best results, we recommend uploading a specification in a standardized format, such as an OpenAPI or GraphQL schema that includes full details on endpoints, supported content types, and the structure of request and response objects.
In the absence of a single standardized API spec, you can try uploading other files that contain similar information, such as a Postman collection, code files, sample request and response objects, HAR logs captured by Chrome DevTools, or even a text description.
Provide an API description
The API description can include any information that isn’t captured in uploaded files or any details that are more convenient to write as text than to upload as file, such as authentication instructions, requirements for headers, or a sample cURL request and response for an endpoint that you want to test.
Launch the API Test Editor
After describing the intent of the test and providing the API specification, fill out the remaining information on the test creation form and click on Create test.
When the API Test Editor launches, mabl’s AI uses the test intent and API specification to generate your test. Tasks break down the overall intent of the test into smaller goals.
If you’re satisfied with the preview, click on Create test to load the generated steps and build out the test.
If you’re looking for something different, modify the test intent and click on Generate new outline.
Build out the test
Review each step in the test and make adjustments as needed. Steps created with GenAI Test Creation can include the following:
- Step name
- URL
- Method
- Headers
- Request body
- Assertions
- Variables
Run the steps in the API Test Editor to validate whether everything works as expected and update as needed.
During the initial test creation session, you can delete all the steps in the test to return to the initial test preview page and generate a new outline.
Limitations
- mabl uses generative AI to generate your API test steps, and is limited by the information provided. There may be mistakes in generated steps if insufficient information is provided on the API, or if the schema is too complex for mabl to interact with.
- Generated API test steps do not include snippets, so more complex validations or pre-request and post-request scripts will not be created.
- The OAuth 1.0 auth type will not be generated. If you want to authenticate to your API using OAuth 1.0, you can generate the test and manually add the OAuth 1.0 settings on the test level.
- API flows are not currently supported in GenAI Test Creation.
- GenAI Test Creation is biased towards English. If you define the test intent in a non-English language, the API Test Editor may still generate tasks and assertions in English.