Open gionn opened 4 years ago
Hi, I am in the middle of migrating an old Spring MVC 4.x application to Spring Boot 2.x.
I was using the upstream spring-test-dbunit that didn't get any updates recently.
I think I've found a bug related on how the test-context is handled when the Junit rule timeout is used:
11:04:33.493 DEBUG BaseDbUnitTest - Starting test baseTest in SpringBootTestTest [Time-limited test] 11:04:33.509 INFO TransactionContext - Began transaction (1) for test context [DefaultTestContext@52cdebea testClass = SpringBootTestTest, testInstance = com.liberologico.cloudesire.cmw.test.SpringBootTestTest@68edb496, testMethod = baseTest@SpringBootTestTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@1d248383 testClass = SpringBootTestTest, locations = '{}', classes = '{class com.liberologico.cloudesire.SpringBootCmw}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@343570b7, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@236e3f4e, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@152aa092, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@4cc8eb05, org.springframework.boot.test.context.SpringBootTestArgs@1], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@5343ec9a]; rollback [true] [Time-limited test] 11:04:33.604 WARN TestContextManager - Caught exception while invoking 'beforeTestMethod' callback on TestExecutionListener [com.github.springtestdbunit.DbUnitTestExecutionListener@727eb8cb] for test method [public void com.liberologico.cloudesire.cmw.test.SpringBootTestTest.baseTest()] and test instance [com.liberologico.cloudesire.cmw.test.SpringBootTestTest@68edb496] [Time-limited test] java.lang.NullPointerException: null at com.github.springtestdbunit.DbUnitRunner.loadDataset(DbUnitRunner.java:245) at com.github.springtestdbunit.DbUnitRunner.loadDataSets(DbUnitRunner.java:212) at com.github.springtestdbunit.DbUnitRunner.setupOrTeardown(DbUnitRunner.java:189) at com.github.springtestdbunit.DbUnitRunner.beforeTestMethod(DbUnitRunner.java:79) at com.github.springtestdbunit.DbUnitTestExecutionListener.beforeTestMethod(DbUnitTestExecutionListener.java:180) at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:289) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:288) at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:282)
Sorry, I've digged deeper and found that the culprit was:
@Rule public Timeout globalTimeout = new Timeout( 2, TimeUnit.MINUTES );
Hi, I am in the middle of migrating an old Spring MVC 4.x application to Spring Boot 2.x.
I was using the upstream spring-test-dbunit that didn't get any updates recently.
I think I've found a bug related on how the test-context is handled when the Junit rule timeout is used: