2
我想测试使用JUnit测试中的Spring框架的多个文件。到目前为止,我的进步是我可以阅读使用Spring框架global.properties从目录中的文件。我的测试类从目录中读取文件,并在@Before我阅读这些文件,并通过一个送一个给我@Test函数生成测试结果。如何执行在JUnit测试测试多个文件
@RunWith(MultiThreadedRunner.class)
@ContextConfiguration(locations = {"/applicationContext.xml"})
public class FullCycleTest {
@Before
public void beforeUploadTest() throws Exception {
new TestContextManager(getClass()).prepareTestInstance(this); // TestContextManager is responsible for managing Spring TestContext Framework
this.resourcesTest = new ResourcesTest(); // get instance of ResourceTest class
this.uploadTest = new UploadandJobTest();
this.folder = new File(resourcesTest.basePath());
this.file = new ArrayList<>();
File[] fileEntry = folder.listFiles();
this.uploadControllerTest = new UploadControllerTest();
this.uploadResult = new UploadJSON();
/******File upload read*****/
for (int i = 0; i < fileEntry.length; i++) {
if (fileEntry[i].exists()) {
file.add(String.valueOf(fileEntry[i]));
System.out.println("Testing for file" + file);
}
}
}
@Test
public void UploadandJobTest() {
for (String s : file) {
uploadTest.uploadAndJobTest(s);
uploadControllerTest.upload_stl_response(s);
}
}
所以在@Test中我可以在测试中逐个测试每个文件。我想做的是同时测试所有的文件,而无需等待完成每个文件。我知道有TestSuite的可以执行的TestSuite里面所有的测试。在我的情况下,这是没有用的。有没有什么办法可以通过编程方式创建@Test而不用任何注释@Test ??谢谢