You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the latest version 1.17.4 of governator-test-spock, several NullPointerException are thrown when using BEFORE_EACH_TEST_METHOD as InjectorCreationMode in Spock Spec.
Below are the stacktraces:
`
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.prepareTestFixture(AnnotationBasedTestInjectorManager.java:76)
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.cleanUpMethodLevelConfig(AnnotationBasedTestInjectorManager.java:86)
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.cleanUpInjector(AnnotationBasedTestInjectorManager.java:90)
`
To reproduce, one just need create and run the following spock test class:
Hi,
On the latest version 1.17.4 of governator-test-spock, several NullPointerException are thrown when using BEFORE_EACH_TEST_METHOD as InjectorCreationMode in Spock Spec.
Below are the stacktraces:
`
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.prepareTestFixture(AnnotationBasedTestInjectorManager.java:76)
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.cleanUpMethodLevelConfig(AnnotationBasedTestInjectorManager.java:86)
java.lang.NullPointerException
at com.netflix.governator.guice.test.AnnotationBasedTestInjectorManager.cleanUpInjector(AnnotationBasedTestInjectorManager.java:90)
`
To reproduce, one just need create and run the following spock test class:
@ModulesForTesting(injectorCreation = InjectorCreationMode.BEFORE_EACH_TEST_METHOD) class ExampleSpec extends Specification { def "dummy test"() { expect: 1 + 1 == 2 } }
The fix seems to be simple to implement, in GovernatorExtension the line of code below needs to be moved before calling prepareTestFixture.
if (InjectorCreationMode.BEFORE_EACH_TEST_METHOD == annotationBasedTestInjectorManager.getInjectorCreationMode()) { annotationBasedTestInjectorManager.createInjector(); }
The text was updated successfully, but these errors were encountered: