java在web应用程序中将对象传递给Junit测试
鉴于无法使用@Parameters在JUnit类中创建对象,如何将对象传递给JUnit测试
事实上,该对象是由web应用程序之外的服务动态创建的,我想在创建剩余流程(使用该对象的流程)中所需的大量资源之前测试它是否有效
编辑:
public void doService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
MyObject myObject = ... //Get Object from external service
JUnitCore runner = ... //Create runner
runner.run(MyTestCase.class); //throws exception when objet is not valid
...//Create the heavy resources and delegate to custom process
}
MyTestCase:
public class MyTestCase{
@Test
public void testValidObject(){
MyObject myObject = ...//How to retrieve MyObject here?
}
}
共 (0) 个答案