I use the Java Juint Framework to organize the automated tests, so I need a brief introduction to the Juint framework
First of all, it is recommended that Baidu Juint frame, first have a rough understanding
The so-called Interface Automation test will send a variety of requests to each interface in multiple interfaces, and its main thinking is the following way
Can think of, we want to simulate the test, is a set of code, deployed on the local or test server, send the request to the server, in the various ways shown in order to request each interface, and then the request after the return of the value or other to verify that the test is expected to pass
So the mainstream interface Test Java framework (please forgive the author technology, temporarily only Java) is Juint and testng, testng is Juint upgrade version, they have what benefit? This article roughly describes the Juint framework.
What does the generic Java code look like? There is a Mian function to make the request, then the above code will need 3 ABC3 package, under a This folder also have 3 class to be a parameter group, three requests, in each request if all use the same sending method, Then each method first declares a map, then passes the different parameter groups into the map, makes the request and accepts the data, and then makes the assertion check.
Juint framework is characterized by the existence of some special identification, such as @[email protected] @Before, the following will be about the ~, first in the ideal of the original Shiyan class write down the following code
Package ZLR;
Import org.junit.*;
public class Shiyan {
int x=0;
static int y=0;
@BeforeClass
public static void Setup () throws Exception
{
y++;
}
@Before
public void Setup1 () throws Exception
{
x=x+1;
}
@After
public void Teardown () throws Exception
{
Assert.assertequals (x,2);
}
@AfterClass
public static void Setup2 () throws Exception
{
y++;
}
@Test
public void ABC1 () throws Exception
{
x + +;
SYSTEM.OUT.PRINTLN (x);
System.out.println (y);
}
@Test
public void ABC2 () throws Exception
{
x + +;
SYSTEM.OUT.PRINTLN (x);
System.out.println (y);
}
}
which can be seen, before,after,test these kinds of comments, juint framework commonly used comments in addition to these 3 kinds of 2, beforeclass and Afterclass, the approximate implementation flowchart is as follows
The Juint framework does not have a main function, can contain multiple test comment code, usually have some initialization in the Beforeclass, then call the before code, then call the first test code, then call after code, and then again the next iteration, Once before, the next Test then again after the code, and then the test call after the end of the call Afterclass code to end, other interfaces can be placed in different classes to do, such as A.class,b.class and so on
So here for the A interface, it is possible to put the parameter in a different test, and then put some initialization work in before and Beforeclass, array collation and some post-operation in after and Afterclass so that you can run
On the other hand, as you can see above, the first Test in the code adds an x, but it works, from the effect, it's good, X is independent of each other, which is the biggest difference from the for loop and main function ~
OK, the purpose of this article is to juint the framework of popular science, next, I will say if the code of the Juint framework is automatically run
A brief introduction to the Java Automation-juint framework