Class DbUnitRunner
java.lang.Object
com.github.mjeanroy.dbunit.core.runner.DbUnitRunner
Generic class to run DbUnit before/after test method invocation.
-
Constructor Summary
ConstructorsConstructorDescriptionDbUnitRunner(Class<?> testClass) Create runner and extract the JDBC Connection factory from thetestClassthat should be annotated withDbUnitConnection.DbUnitRunner(Class<?> testClass, JdbcConnectionFactory factory) Create runner.DbUnitRunner(Class<?> testClass, DataSource dataSource) Create runner. -
Method Summary
Modifier and TypeMethodDescriptionvoidUnload data set after test execution: Get new SQL connection. Remove DataSet and execute tear down operation. Close SQL connection.voidbeforeTest(Method testMethod) Load data set before test execution: Get new SQL connection. Load DataSet and execute setup operation. Close SQL connection.Get JDBC Connection to the target database.Getfactory
-
Constructor Details
-
DbUnitRunner
Create runner.
DbUnit DataSet will be automatically detected:- If method to launch contains
DbUnitDataSetannotation, it is used. - If
DbUnitDataSetannotation is not found, a log is displayed, but runner will not failed.
- Parameters:
testClass- Class to test.factory- Factory to get new SQL connection before and after test methods.- Throws:
DbUnitException- If dataSet parsing failed.
- If method to launch contains
-
DbUnitRunner
Create runner.- Parameters:
testClass- Class to test.dataSource- DataSource to get new SQL connection before and after test methods.- Throws:
DbUnitException- If dataSet parsing failed.- See Also:
-
DbUnitRunner
Create runner and extract the JDBC Connection factory from thetestClassthat should be annotated withDbUnitConnection.- Parameters:
testClass- The tested class.
-
-
Method Details
-
beforeTest
Load data set before test execution:- Get new SQL connection.
- Load DataSet and execute setup operation.
- Close SQL connection.
- Parameters:
testMethod- Method to execute.
-
afterTest
Unload data set after test execution:- Get new SQL connection.
- Remove DataSet and execute tear down operation.
- Close SQL connection.
- Parameters:
testMethod- Executed method.
-
getFactory
-
getConnection
Get JDBC Connection to the target database.- Returns:
- SQL Connection.
-