Diagnostics are poor when using JUnit 5 and accidentally using @BeforeAll rather than the required @BeforeEach
See original GitHub issueHi,
I updated a project with spring-boot-dependencies to 2.0.4.RELEASE this morning, which in turn updated spring-restdocs dependency to version 2.0.2.RELEASE (upgraded from 2.0.1.RELEASE). I am also using spring-restdocs-restassured.
The version update of spring-restdocs to 2.0.2.RELEASE seems to cause the following issue when invoking requestSpec.when().get("/myUri")
:
java.lang.NullPointerException
at org.springframework.restdocs.ManualRestDocumentation.beforeOperation(ManualRestDocumentation.java:89)
at org.springframework.restdocs.RestDocumentationExtension.lambda$resolveParameter$0(RestDocumentationExtension.java:58)
at org.springframework.restdocs.restassured3.RestAssuredRestDocumentationConfigurer.filter(RestAssuredRestDocumentationConfigurer.java:69)
at org.springframework.restdocs.restassured3.RestAssuredOperationPreprocessorsConfigurer.filter(RestAssuredOperationPreprocessorsConfigurer.java:46)
at io.restassured.filter.Filter$filter.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:144)
at io.restassured.internal.filter.FilterContextImpl.next(FilterContextImpl.groovy:72)
From a quick debugging, I could find that ManualRestDocumention
doesn’t have a context (is null) when RestDocumentationExtension.resolveParameter(...)
invokes beforeOperation()
. I also found that RestDocumentationExtension
was modified in 2.0.2.RELEASE.
When I force spring-restdocs dependencies to version 2.0.1.RELEASE (while keeping spring-boot-dependencies to version 2.0.4.RELEASE), the issue goes away.
See also, stackoverflow post
Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (6 by maintainers)
Thank you, @sbrannen!
Note: I’m not condoning the use of
@BeforeEach
and@AfterEach
on a@Test
method. 😉