...
There are two test data forms currently - acceptance_test_dump.sql and dbUn datasets. DbUnit is deprecated. As part of MIFOS-4590 , there is currently an on-going effort to refactor the current suite of acceptance tests to minimize dependency on the DB unit based XML datasets.
Test data are stored in the following locations:
No Format |
---|
db/src/test/resources/sql/acceptance_test_dump.sql acceptanceTests/src/test/resources/dataSets (DbUnit) |
Procedure for maintaining acceptance_test_dump.sql
If you want to make changes to the dump by using the application
Import all data from the dump into the database.
Use the application to setup/change (only) the data you want.
Export the data using following command.
mysqldump -u <your_user> -p<your_password> <your_database> --complete-insert --extended-insert --skip-add-locks --skip-comments --skip-quote-names > ~/acceptance_test_dump.sql
When commiting changes commit acceptance_test_dump.sql file as well.
If you want to make changes to the dump manually
Edit acceptance_test_dump.sql
When commiting changes push acceptance_test_dump.sql file as well.
DbUnit dependency
A new test group, no_db_unit, has been introduced to categorize tests that do not need DB unit dependency. Currently, the Maven POM for acceptance tests, ensures that all tests in the no_db_unit group are executed prior to executing the rest of the acceptance tests. This ensures that the no_db_unit group of tests do not inadvertently depend on the XML data sets used by the older tests.
In summary, if you are adding an acceptance test to the current suite, ensure that you look at an existing test in the no_db_unit category and see how the test data is setup & managed. Try & avoid loading your seed data from an XML dataset whenever possible.
DbUnit approach - deprecated and should not be used for new tests
There are two different kinds of data sets, validation and start data sets. Validation data sets are used to make sure that at the end of a test, the database looks correct. As of Jan 2011, we are working to eliminate the use of validation data sets. Start data sets are used to set up a suitable environment for each test case and they're usually loaded at the very beginning of the test.
...
Upgrading data sets generated from an earlier database version to the current database version is documented at the DataSetUpgradeUtil page . Read this thread for more information about the data set upgrade process.
Writing Acceptance Tests
Here is a brief outline of the steps to follow in order to create an acceptance test:
...
Here is an example of an existing test from GroupTest.java:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Test(sequential = true, groups = {"group","acceptance","ui"}) @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception public void createGroupInPartialApplicationStateTest() throws Exception { initRemote.dataLoadAndCacheRefresh(dbUnitUtilities, "acceptance_small_001_dbunit.xml", dataSource, selenium); CreateGroupEntryPage groupEntryPage = loginAndNavigateToNewGroupPage(); CreateGroupSubmitParameters formParameters = getGenericGroupFormParameters(); CreateGroupConfirmationPage confirmationPage = groupEntryPage.submitNewGroupForPartialApplication(formParameters); confirmationPage.verifyPage(); GroupViewDetailsPage groupDetailsPage = confirmationPage.navigateToGroupDetailsPage(); groupDetailsPage.verifyPage(); groupDetailsPage.verifyStatus("Partial Application*"); } |
Might be written something like:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
\* \* Given Center exists, \* And there is a user with rights to create a group, \* When I login in as user "mifos" \* And I create a Group with generic parameters \* And I view Group Details \* Then Group status is "Partial Application" */ @Test(sequential = true, groups = {"group","acceptance","ui"}) // http://mifosforge.jira.com/browse/MIFOSTEST-300 @SuppressWarnings("PMD.SignatureDeclareThrowsException") // one of the dependent methods throws Exception public void createGroupInPartialApplicationStateTest() throws Exception { //Given initRemote.dataLoadAndCacheRefresh(dbUnitUtilities, "acceptance_standard_dbunit.xml", dataSource, selenium); Center center = createCenter(getGenericCenterFormParameters()); //When login("mifos"); Group group = createGroup(center, getGenericGroupFormParameters()); GroupDetails groupDetails = viewGroupDetails(group); //Then groupDetails.verifyStatus("Partial Application*"); } |
...