使用不同的数据多次运行相同的JUnit测试用例 [英] Running the same JUnit test case multiple time with different data
本文介绍了使用不同的数据多次运行相同的JUnit测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在进入下一个测试用例之前,有没有办法告诉JUnit多次运行不同数据的特定测试用例?
Is there there any way to tell JUnit to run a specific test case multiple times with different data continuously before going on to the next test case?
推荐答案
看看 junit 4.4理论:
import org.junit.Test;
import org.junit.experimental.theories.*;
import org.junit.runner.RunWith;
@RunWith(Theories.class)
public class PrimeTest {
@Theory
public void isPrime(int candidate) {
// called with candidate=1, candidate=2, etc etc
}
public static @DataPoints int[] candidates = {1, 2, 3, 4, 5};
}
这篇关于使用不同的数据多次运行相同的JUnit测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文