Has anybody run unit tests with MySQL instead of H2 in-memory database? If I modify BaseContextSensitiveTest.useInMemoryDatabase to return false the tests fail (Spring cannot open connection). I guess that at least setupDatabaseConnection and getRuntimeProperties must be modified.
The use case I have seen for having useInMemoryDatabase() return false is that it will look at your regular runtime.properties file and connect to an existing OpenMRS database. It will not populate it with any test data in this case.
Here is an arbitrary example that I presume is doing that:
Turns out it was a problem with the openmrs-runtime.properties
I have OpenMRS installed on Tomcat, and the folder where the properties is located is C:\Application Data\OpenMRS
On the other hand, running the tests from Eclipse the folder is C.\Users\lluis\Application Data\OpenMRS
I copied the properties manually and now the unit tests connect to the DB (which is MariaDB). Almost all of them fail, but I don’t think it’s because of the DB. Typical errors: FK constraint violation, privileges required etc.
I suspect that making the unit tests run successfully on a DB will be a lot of work.
I presume the issue is that the data in the non-in-memory db you’re pointing to is nothing like standardTestDataset.xml.
You’d need to wrap the entire test suite with setting up a new empty DB, and change the BaseContextSensitiveTest so that it does standard test setup even if it’s not an in-memory db.