我编写了简单的方法,该方法执行在我的测试类中:DataContainerTest.class,AnotherTest.class。
npm v5.6.0
此方法无效不适用于我正在使用 annotation function testForLetter(character){
try{
//Variable declarations can't start with digits or operators
//If no error is thrown check for dollar or underscore. Those are the only nonletter characters that are allowed as identifiers
eval("let " + character + ";");
let regExSpecial = /[^\$_]/;
return regExSpecial.test(character);
}
catch(error){
return false;
}
}
testForLetter("!"); //returns false;
testForLetter("5"); //returns false;
testForLetter("ن"); //returns true;
testForLetter("_"); //returns false;
的另一个类CommandsTest.class。参见下面的输出:
public static void main(String [] args) throws Exception {
Result result = JUnitCore.runClasses(DataContainerTest.class, AnotherTest.class);
System.out.println(result.getRunCount());
System.out.println("Total number of tests " + result.getRunCount());
System.out.println("Total number of tests failed: " + result.getFailureCount());
for(Failure failures : result.getFailures()){
System.out.println(failures.getMessage());
}
System.out.println(result.wasSuccessful());
}
这是 CommandsTest.class
的示例@RunWith(PowerMockRunner.class)
在AndroidStudio中按运行按钮时,所有测试均通过,但我自己的TestRunner无法在此类中运行测试。
答案 0 :(得分:0)
使用@RunWith(PowerMockRunner.class)
批注处理类的最佳方法是将其放入android项目的默认测试源,然后通过gradle test
运行所有测试。您实际上不需要编写自己的测试运行程序。