我有几个不同的字符串数组,例如
private static final String[] allowed = {"-", "_", "@", ".", "`", "[", "]", "'", "#", "?", "&", "!", "{", "}"};
private static final String[] disallowed = {" ", "/", "*", "~", "|","\\", "<", ">", "\"", "=", "%", "$", "^"};
我有三个测试创建用户的测试,我们称之为测试A,B和C.
如果我想针对allowed
中的每个字符串单独运行测试A,针对disallowed
中的每个字符串测试B,并且测试C没有参数并且只运行,是否有办法完成所有三合一或我是否需要将它们拆分为单独的类(目前测试A,B和C是分开的类)?
我正在研究Junits的理论,看起来有一些可能性,但理论是相当无记录的,这引导我到这里来。感谢您的任何指示或建议。
答案 0 :(得分:1)
我在GitHub上有一个库,我在其中实现了@TestOn
,它允许所有原始类型。
答案 1 :(得分:0)
恕我直言@FromDataPoints可以帮助你。
@DataPoints ("allowed")
private static final String[] allowed = {"-", ... }
@DataPoints ("disallowed ")
private static final String[] disallowed = {" ", ... }
@Theory
public void testAllowed(@FromDataPoints("allowed") String s) { ... }
@Theory
public void testDisallowed(@FromDataPoints("disallowed") String s) { ... }