-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDataProviderTest.java
More file actions
38 lines (32 loc) · 1.11 KB
/
DataProviderTest.java
File metadata and controls
38 lines (32 loc) · 1.11 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
37
38
package io.github.walterinsh.basic;
import io.github.walterinsh.Method;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
* @DataProvder supplies data for tests. And it saves your code and gives more readabilities.
* Created by Walter on 16-9-5.
*/
public class DataProviderTest {
@DataProvider(name = "number set")
public Object[][] numberSet(){
return new Object[][] {
{"-1"},
{"123"},
{"1.1"}};
}
@DataProvider
public Object[][] wordSet(){
return new Object[][] {
{"A"},
{"1.1.1.1"}};
}
@Test(dataProvider = "number set")
public void testWithNumberStringShouldNoException(String preparedData) throws Exception {
Method.onlyAcceptNumberString(preparedData);
}
//use default data provider's name(method name)
@Test(dataProvider = "wordSet", expectedExceptions = IllegalArgumentException.class)
public void testWithIllegalStringShouldFail(String preparedData) throws Exception {
Method.onlyAcceptNumberString(preparedData);
}
}