api deployment architecture api framework

  1. Create a src folder to store test-related codes, right-click on the project -> New -> Folder, and fill in the file name: src.

  2. According to the principle of data and code separation and public method extraction, my code structure is divided as follows:

  3. Scripting order

3.1 Global configuration file (GlobalSettings.java)

Store some project global variables, such as baseUrl, timeout, etc.;

3.2 Http protocol implementation (HttpClientHelper.java)

Implement related requests according to the protocol used by the project interface. Our project has two methods, one is to use NameValuePair to encapsulate request parameters, and the other is to use JSONObject to encapsulate request parameters, so codes are implemented for both methods.

3.3 Interface implementation (GList_API.java)

Take "Create G List" as an example to implement this interface:

3.4 Prepare test data (TestData.java)

Prepare test data for the interface.

3.6 Test case suit (GListCURD.java)

  1. Test case debugging and execution

After writing all the use cases according to step 3, the debugging and execution of the use cases can be carried out.

4.1 Test case script debugging

Right click on the test case suit GListCURD.java in step 3, "Debug as" or "Run as" -> "TestNG Test" to run the script.

4.2 Test case script execution

There are two ways to run the script, testNG or ant.

Use testNG to run, the operation is as in step 4.1.

To run with ant, you need to create xml, please refer to build.xml and smokeTest.xml in the resource library. If you need to generate a testNG report, you also need to download the test-result.xsi file.

4.3 Beautified running result report

Guess you like

Origin blog.csdn.net/wbryze/article/details/131172517
API