使用不同的数据多次运行相同的 JUnit 测试用例

2023-12-19

有没有办法告诉 JUnit 在继续下一个测试用例之前连续使用不同的数据运行特定的测试用例多次?


看看Junit 4.4 理论 http://junit.sourceforge.net/doc/ReleaseNotes4.4.html:

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};
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用不同的数据多次运行相同的 JUnit 测试用例 的相关文章

随机推荐