我有我需要在一个测试套件之一运行2个测试类是RestaurantModelTest
另一个是CartModelTest.class
:不能运行Android测试套件:在线程“主要”抛出java.lang.ClassNotFoundException异常
@Config(sdk = 16, manifest = "src/main/AndroidManifest.xml")
@RunWith(RobolectricTestRunner.class)
public class RestaurantModelTest {
//setUp code here...
@Test
public void testFindByLocation() throws Exception {
//test code here
}
}
所以我跟着一些在线教程和他们指定要创建一个TestSuite类像这样我的2班进行测试:
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
RestaurantModelTest.class,
CartModelTest.class
})
public class ModelsTestSuite {
}
然后,我必须创建一个TestSuiteRunner类:
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TestSuiteRunner {
public static void main(String[] args){
Result result = JUnitCore.runClasses(ModelsTestSuite.class);
for (Failure failure : result.getFailures()){
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
}
我使用Android的工作室,当我讨厌右键 - >运行TestSuiteRunner ......主()我得到Exception in thread "main" java.lang.ClassNotFoundException:
任何帮助,非常感谢!
我想你错过了一些jar文件 – SpringLearner