-
Notifications
You must be signed in to change notification settings - Fork 110
/
Copy pathTestDemo1.java
56 lines (45 loc) · 1.3 KB
/
TestDemo1.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
54
55
56
package com.test.testcase;
import java.lang.reflect.Method;
import org.testng.Assert;
import org.testng.Reporter;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import com.test.report.ZTestReport;
@Listeners({ZTestReport.class})
public class TestDemo1{
@BeforeMethod(description="测试方法前初始化")
public void beforeMethod(Method m){
if("testDemo3".equals(m.getName())){
int a = 1/0;
System.out.println(a);
}
}
@Test(description="测试DEMO")
public void testDemo(){
Reporter.log("this is demo!");
int a = 1/0;
System.out.println(a);
Assert.assertEquals("a", "b", "should be equals.");
}
@Test(description="测试DEMO1")
public void testDemo1(){
Reporter.log("this is demo!");
Assert.assertEquals("a", "b", "should be equals.");
}
@Test(description="测试DEMO2",dataProvider="test")
public void testDemo2(int a){
Reporter.log("this is demo!");
Assert.assertEquals(a, 1, "should be equals.");
}
@Test(description="测试DEMO3")
public void testDemo3(){
Reporter.log("this is demo!");
Assert.assertEquals("a", "a", "should be equals.");
}
@DataProvider(name="test")
public Object[][] dataProvider(){
return new Object[][]{{1},{2}};
}
}