-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUsePriorityTest.java
More file actions
36 lines (29 loc) · 1.02 KB
/
UsePriorityTest.java
File metadata and controls
36 lines (29 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package io.github.walterinsh.basic;
import io.github.walterinsh.SharedClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
/**
* This class shows how to use priority to control the order of tests execution.
*
* When we design tests, try not changing class status when tests run. Because it may affect
* other tests. In this case, "sharedField" is the status. The first test method changes the status
* and it affects the second test method.
*
* But sometimes, changing status is necessary or unavoidable. Controlling the order is important in this
* situation.
*
* Mark methods with priority. Lower priorities will be scheduled first.
*
* Created by Walter on 11/15/15.
*/
public class UsePriorityTest {
@Test(priority = 1)
public void testOne() throws Exception {
SharedClass.sharedFiled = 2;
assertEquals(SharedClass.sharedFiled, 2);
}
@Test(priority = 0)
public void testTwo() throws Exception {
assertEquals(SharedClass.sharedFiled, 0);
}
}