-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJUnitExample.java
executable file
·53 lines (42 loc) · 1.18 KB
/
JUnitExample.java
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.Description;
import org.junit.runner.RunWith;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
/** äåìîíñòðàöèÿ âîçìîæíîñòåé JUnit */
@RunWith(SimpleRunner.class)// äàííàÿ àííòîöèÿ äàåò ðóêîâîäñòâî ïî çàïóñêó JUnit òåñòà ñîáñòâåííûì Runner-îì
public class JUnitExample {
private int controlValue=0;
public JUnitExample(){
}
/* public JUnitExample(int value){
this.controlValue=value;
}
*/
public int getControlValue(){
return this.controlValue;
}
@Before
public void BeforeControl(){
System.out.println("Run before test");
this.controlValue=5;
}
@After
public void AfterControl(){
System.out.println("Run after test");
this.controlValue=0;
}
@Test(timeout=5)
public void Control(){
assertTrue(this.controlValue==5);
System.out.println("test was started");
}
public static void main(String[] args){
// çàïóñê òåñòîâ èç êîìàíäíîé ñòðîêè
org.junit.runner.JUnitCore.main("JUnitExample");
}
}