@Parameters를 사용하여 JUnit 클래스에서 객체를 만들 수 없다는 사실을 고려하여 객체를 JUnit 테스트에 전달할 수 있습니까?웹 응용 프로그램의 Junit 테스트에 객체 전달
실제로 웹 응용 프로그램 외부의 서비스에서 객체를 동적으로 만들고 나머지 프로세스 (객체를 사용하는)에 필요한 많은 리소스를 만들기 전에 객체가 유효한지 테스트하고 싶습니다.
편집 :
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?
}
}
일부 코드 공유 – Kowser
내가 원하는 것을 공유했습니다. –