Since its inception, dbunit has had equality comparison for expected vs actual data results. Spring dbunit provides integration between the spring testing framework and the. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or exacerbate the damage. The following sections describe the support that the databasemodule and. If you need to manually download dbunit, please obtain it from maven central. You must therefore download slf4j and include slf4japi. Initially i spotted and got pretty interested in unitils, but then i saw the standard spring testcontext. It allows you to setup and teardown database tables. If you are not using maven you can download the unitilswithdependencies. Unit tests for the database layer can be extremely valuable when building enterprise applications, but are often abandoned because of their complexity. Dbunit extension dbunit is a junit extension also usable from ant and maven targeted for databasedriven projects that, among other things, puts your database into a known state between test runs. Spring dbunit provides integration between the spring testing framework and the popular dbunit project. If you for example need mocking for your tests, just include unitilsmock as a dependency.
Modular testing library for unit and integration testing. It is divided into several modules, each of them providing extra support for a certain aspect of your unit and integration tests. If you for example need mocking for your tests, just include unitils mock as a dependency. Please add the extra columns to line 1, or use a dtd to make sure the. For additional examples, refer to the its for the specific test case. If you would also want to load dbunit data sets, just include unitilsdbunit. It enables comparing actual table results to expected results in an equal manner.
Please refer to the dbunit maven repositories page or the dbunit download. If you would also want to load dbunit data sets, just include unitils. Unitils is an open source library aimed at making unit and integration testing easy. If you just want to connect to a test database and dont want to use dbunit. Implementation of dbunits idatabaseconnection interface. If no file name is specified, unitils automatically looks for a data set file that is in the same directory as the test class and has following name pattern. The assertion and dbunitassert classes have assertequals methods for the equality comparisons.
If a class is annotated, a test data set will be loaded before the execution of each of the test methods in the class. This is an excellent way to avoid the myriad of problems that can occur when one test case corrupts the database and causes subsequent tests to fail or. The preferred option is to use dbunit as a dependency to your build. Please refer to the dbunit maven repositories page for more information. Annotation indicating that a data set should be loaded before the test run. Unitils greatly reduces this complexity, making database testing easy and maintainable.
615 1338 1319 503 383 1481 96 886 854 92 429 694 1106 433 194 1073 702 1505 692 1274 233 33 780 448 973 382 165 1204 404 868 556 500 389 1074 913 1015 247 133 1109 1209