Create a New Test Scenario
This article introduces how to create a new test scenario.
Test scenarios are used to combine multiple endpoint requests with some special cases(e.g. conditional judgment, loops, etc.) that may be encountered in practice in an orderly manner, simulating real business processes and forming an automated test unit.
Create Test Scenario
Upon opening Apidog, navigate to “Test” on the left menu bar, and then click the +
next to the search bar to create a new test scenario. Select the appropriate directory for it, and set the priority to complete the creation.
If the newly created API test scenario does not have a suitable directory, you can create a new folder by clicking New Folder in the lower left corner of the Folder drop-down box.
You can also set tags for test scenarios, which can then be used to locate the corresponding test scenarios
Add Test Steps in Test Scenario
When a new test scenario is created, you can start designing it by importing endpoints, endpoint cases, custom requests (can be in cURL form). In addition, you need to set the test conditions and other required fields for it.
To start a test scenario, begin by selecting "Add Step" and then adding an endpoint, choosing either "Import from endpoint" or "Import from endpoint case".
Import from Endpoint
You can import endpoints from the current project as steps in the test scenario. There are two modes when importing endpoints: "Manual" and "Automated." For more detailed instructions, please refer to Sync Data from APIs/API Cases.
Manual
In "Manual" mode, modifications to the endpoint documentation within the project do not have an immediate impact on the endpoints in the test steps. Synchronization of test data only occurs when testers activate the "Manual" button. It is important to note that alterations made to the test step data will not update the endpoint documentation, even when clicking for "Manual Sync". Instead, clicking this button enables the test scenarios to retrieve information from the endpoint documentation for synchronization purposes.
Automated
In the "Automated" mode, any changes in the endpoint documentation within the project will be updated synchronously in the test steps.
If you need to test endpoints from other projects in one test scenario, please refer to Import Endpoints/Cases from Other Projects to Test Steps.
Import from Endpoint Case
You can choose to import endpoint cases from the current project or other projects. There are two modes when importing endpoint cases: "Copy" and "Reference".
Copy
When importing an endpoint case as "Copy", the parameters in the endpoint case will also be copied into the test steps. They will be independent of each other, and changes in each will not affect the others. Manual sync can be selected.
Reference
When importing an endpoint case as "Reference", it will directly use the endpoint case from the original project for the request.
Add Custom Request
In a working process, you may need to call an endpoint outside of the project, such as a third-party payment endpoint.
You can add a custom API request in the test steps. The custom request can be any HTTP request, including common GET
, POST
, PUT
, DELETE
, etc.
Import from cURL
In a real working processes, many endpoint requests are presented in the form of cURL
command lines. You have the option of importing cURL requests into the test steps, with just a single click.
Testing Process Control
You can add process control (such as Group, If, ForEach loop, For loop, and Wait) in the test scenario. This further meets the usage of more complex test scenarios/process control, ultimately solving complex scenario testing with automated testing features. For detailed instructions, please refer to Testing Process Scenario.
Import steps from Other Test Scenarios
You can clone the test steps or process control conditions by importing from other test scenarios within the same project.
Reference Other Test Scenarios
You can reference other test scenarios as a test step. There are two use cases:
- If your business process has some common, reusable API test steps, you can compile these steps into a small test scenario and then reference it directly in other wider test scenarios.
- If you need to regress the mainstream process of the entire product, you can refer to the various sub-test scenarios in the test scenario for assembly, and complete the test regression work of all mainstream processes with one click.
To prevent infinite loops and situations where the test scenario cannot stop running normally, the feature of referencing other test scenarios cannot reference the original test scenario itself.
Design Test Scenarios
Clicking any test step will automatically enter the design mode. In this mode, you have a larger operating page to better and more efficiently fill in the detailed content of each test step. The left side of the page is the overall flow of the test scenario, and the right side is the details of the selected test step. Endpoint requests and testing process control components will have different display panels.
You can use the "⬆️" and "⬇️" keys to quickly switch between the selected test steps in this mode.
In the design mode, you can edit multiple steps and then click the "Save All" button in the top left corner to save all the changes.
If any step has unsaved changes, that step will be marked with a dot in the list bar on the left. Remember to always save the changes you have made.