EoLinker AMS is currently the first platform to support online API automated testing. EoLinker AMS offers two automated testing solutions:
1. Simple mode: full UI interface, complete slightly complex API testing without writing any code
2. Advanced mode: Code interface, through writing very little Javascript code, can achieve powerful API automation testing
In general, automated testing involves the following aspects:
1. Set the API test sequence freely;
2. There is data association between apis. For example, request parameters of later interfaces are bound to return results of earlier interfaces;
3. Verify the returned results.
4. Data processing is supported, for example, password encryption during login interface testing.
5. Support advanced code use cases, can use code to achieve the purpose of controlling the test process, the general language is JS;
6. EoLinker supports all the functions mentioned above, and is currently the only product in the world that supports the UI interface to create automated tests, which is very convenient for automated tests and has a much better user experience than tools like Postman.
This article focuses on documenting automated tests in advanced (code) mode. Advanced Test automation Tutorial: Click here.
Singleton and use cases
Singletons are the basic unit below automated testing. In layman’s terms, singletons are “test conditions and results for a single API.” For example, there is a user login interface that passes ABC and 123 as request parameters and returns “OK” as a result of success.
A use case is a collection of multiple singletons. A use case can contain 1 to infinite singletons and combine these singletons in sequence. For example, test the complete user login process (register – login – judge login status – log out).
Note: In advanced mode, singletons are concentrated in use cases in the form of code, so they don’t formally look like simple mode with the obvious concept of singletons and use cases. In the use case list page, select the use case type as advanced [code mode] to create an advanced use case:
2. Environment variables
Like Postman, eoLinker provides environment variables to help users quickly switch between testing API environments without changing the API (for example, the parameters and addresses of the development and production environments may be different).
The difference is that eoLinker environment variables are more powerful. In addition to setting global variables, eoLinker can set all API address prefixes, request headers and other information.
Create a good environment in the environment management, in the automatic test can be switched according to different environment at any time, very convenient.
Create use cases
If you have already entered the API information in interface management, you can directly import the interface document when creating a singleton, which saves a lot of time. Or we can manually enter the singleton information.
These include:
1.API URL (URL)
2. Request Method
3. Headers
4. Request Parameters (Params)
5. Set timeout (timelimit)
Unlike the simple mode, this information is presented in Javascript code. But eoLinker has very simple API template rules, so very little code is required to fully describe the API information (the code in red) :
The API information shown in the figure above is:
Request URL: https://www.eolinker.com
Request mode: POST
Request header: empty
Request parameters: type form-data (default), name=hello, password=world
Timeout limit: 300 milliseconds
After executing the request, determine whether the result is equal to “000000”. If not, use eo.stop() to output an error message and stop the test; otherwise, use eo.info() to output a prompt message and continue the test.
When all tests do not encounter eo.stop() or unexpected termination (such as no response, timeout, etc.), the use case test will be judged as successful, otherwise it will fail. All tests will pop up a test report after the test for easy verification: