Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added some words, links, and formatting about standardTestDataset

...

By default, the Context is set up to run against an in-memory database called hsql. This database is automatically built from the hibernate mapping files that Spring knows about.  

BaseContextSensitiveTest classes will automatically load standardTestDataset.xml, and you may use any object defined there for your tests. 

To insert a super user, call BaseContextSensitiveTest.initializeInMemoryDatabase(). This inserts the data in initialInMemoryTestDataSet.xml.

To authenticate your test to the Context object, call authenticated(). This will pop up a box asking the current user for an admin/password.To add your own data, call executeDataSet("org/openmrs/synchronization/engine/include/SyncCreateTest.xml"); See

Creating an xml dataset for your unit test

You can write it by hand if you want, but the easiest way is add your own test data xml files.   By convention, test data sets are placed in src/test/resources in the project structure.

It's easiest to generate the xml off of your current openmrs mysql database. Use the org.openmrs.test.CreateInitialDataSet file to generate it.

You can write data sets by hand as well.   Look at unit test data sets in the source code repository for examples. 

To load your data set,  call 

Code Block

executeDataSet("YourTestDataSyncCreateTest.xml");  You may wish to add the executeDataSet call  to your @Before setup class.

Testing against your own mysql database

...