스프링 오큐의 jvm을 사용하여 서비스 용 나머지 API 용 스프링 레스트 문서를 테스트하려고하지만 프레임 워크가 실행될 때 null 포인터 예외로 끝납니다. Junit 컨텍스트를 초기화 할 수 없습니다.오이를 사용하여 스프링 레스트 문서를 생성 할 수 없음
오류 메시지 :
java.lang.NullPointerException at
org.springframework.restdocs.ManualRestDocumentation.beforeOperation(ManualRestDocumentation.java:90) at
org.springframework.restdocs.JUnitRestDocumentation.beforeOperation(JUnitRestDocumentation.java:76)
코드 :
private AppProperties props;
@Before("@rest") public void beforeScenario() {
JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
System.out.println("jUnitRestDocumentation " +restDocumentation);
spec = new RequestSpecBuilder().addFilter(documentationConfiguration(restDocumentation)).build();
System.out.println("\n spec init .. " +restDocumentation);
}
단계 정의 코드 :이 사용하기위한 것과 같이 JUnitRestDocumentation
를 사용하지 않는
@Given("^create a rest document for VHR API$")
public void create_a_rest_document_for_VHR_API() throws Throwable {
estAssured.given(spec)
.accept("application/json")
.filter(document("vhrdocument")) .when()
.get(props.getVhrrequesturl() + "/vhrData/{vehicleID}", "5VW4T7AU0FM029999") .then().log().all();
}
오류 메시지 : org.springframework.restdocs.JUnitRestDocumentation.beforeOperation (JUnitRestDocumentation.java에서 org.springframework.restdocs.ManualRestDocumentation.beforeOperation (ManualRestDocumentation.java:90) 에서 java.lang.NullPointerException이 : 76) – ravi
@Autowired 개인 AppProperties 소품; @Before (@ "나머지") 공개 무효 beforeScenario() { JUnitRestDocumentation restDocumentation = 새로운 JUnitRestDocumentation ("타겟/생성-단편"); System.out.println ("jUnitRestDocumentation"+ restDocumentation); spec = new RequestSpecBuilder(). addFilter (documentationConfiguration (restDocumentation)) .build(); System.out.println ("\ n spec init .."+ restDocumentation); } – ravi
단계 정의 코드 : @Given ("^ VHR API를 $의 나머지 문서 작성") 공공 무효 create_a_rest_document_for_VHR_API()의 Throwable를 throw를 { RestAssured.given (사양) .accept ("응용 프로그램/JSON") .filter (document ("vhrdocument")) .when() .get (props.getVhrrequesturl() + "/ vhrData/{vehicleID}", "5VW4T7AU0FM029999") .then(). log(). all(); } – ravi