forked from springtestdbunit/spring-test-dbunit
-
-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Hello,
First, thanks for your contribution to the community.
I get the following error :
08/07/2019 16:59:33 - WARN : Caught exception while invoking 'afterTestMethod' callback on TestExecutionListener [com.github.springtestdbunit.DbUnitTestExecutionListener@224f520c] for test method [public void MyTest.myTestFunction()] and test instance [MyTest@28040a43] | (TestContextManager.java:548)
- java.lang.NullPointerException
- com.github.springtestdbunit.DbUnitRunner.afterTestMethod(DbUnitRunner.java:113)
- com.github.springtestdbunit.DbUnitTestExecutionListener.afterTestMethod(DbUnitTestExecutionListener.java:185)
- org.springframework.test.context.TestContextManager.afterTestMethod(TestContextManager.java:443)
- org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:94)
- org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
- org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
- org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
- at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
- at java.base/java.lang.Thread.run(Thread.java:834)
Adding a test
if (testContext.getConnections() != null)
solves the problem, but I guess the cause is somewhere else.
I'm using :
- Java 11
- JUnit 4.12
- Spring Batch 4.1.2.RELEASE
- Spring Core 5.1.8.RELEASE
- DbUnit 2.5.4
Here is my code :
dbunit-context.xml :
<bean id="dbUnitDatabaseConfig" class="com.github.springtestdbunit.bean.DatabaseConfigBean" lazy-init="true">
<property name="qualifiedTableNames" value="false" />
<property name="skipOracleRecyclebinTables" value="true" />
</bean>
<bean id="dbUnitDatabaseConnection" class="com.github.springtestdbunit.bean.DatabaseDataSourceConnectionFactoryBean" lazy-init="true">
<property name="dataSource" ref="myDataSource" />
<property name="databaseConfig" ref="dbUnitDatabaseConfig" />
</bean>
Test class Java :
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionalTestExecutionListener.class,
DbUnitTestExecutionListener.class })
@DbUnitConfiguration(databaseConnection = { "myConnection" }, dataSetLoader = MyCustomDataSetLoader.class)
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class MyTest {
// ...
}
If you can't find the cause, can you at least turn the error into a warning ?
Thank you in advance.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working