I really use the MySQL database in my unit tests to ensure correctness. When using JUnit, you can do something like this:
@Before public void initialize() { try { dataSource.getConnection().close(); logger.info( "got a connection, so we can assume the configuration is correct..." ); } catch ( Exception e ) { logger.warn( "skipping tests as no connection is available. check spring config: {}", e.getMessage() ); e.printStackTrace(); assumeNoException( e ); } }
This is done before each test, and if it cannot connect to the database, it will skip the test without causing a failure through assumeNoException . Thus, if you need to build a system that is not configured for MySQL, you can, but if your developers set up their system correctly, it will use the installed instance of MySQL. I know this is not a direct answer to your question, but I thought it might be useful anyway ...
source share