我正在尝试在JUNIT4中编写参数化测试,但是我不知道如何制作多个参数,例如:
@ parameter1 {1,2,3,4}
@ test1使用@ parameter1运行测试
@ parameter2 {3,55,66,77}
@ test2使用@ parameters2运行测试
谁能为我提供示例代码片段,将不胜感激。
谢谢。
import org.junit.experimental.theories.Theories;
import org.junit.experimental.theories.Theory;
import org.junit.experimental.theories.suppliers.TestedOn;
import org.junit.runner.RunWith;
@RunWith(Theories.class)
public class SuppliedByTest {
@Theory
public void test1(@TestedOn(ints = { 2, 3, 4, 7, 13, 23, 42 }) int i) {
System.out.println(i);
}
@Theory
public void test2(@TestedOn(ints = { 6, 3, 4, 7, 13, 23, 42 }) int i) {
System.out.println(i);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1054 次 |
| 最近记录: |