Given that you have setup a test scenario where a set of data has been loaded to the In-Memory HSQL DB, you sometimes need to find out the contents of the DB so you can debug your code. Ideally you would know what you added to the DB but sometimes you need find out what you just added to it and even run queries to see what results are being produced.
We followed this tutorial to set our test scenario for these kind of integration tests.
To access the DB while running the tests, follow the steps below
1. Add following piece of code in your @Before method
org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
"--url", "jdbc:hsqldb:mem:testdb", "--noexit"
});
This will kick off a swing application which is fairly well formatted for the purpose.
2. Add a break point using you IDE and run your test in debug mode
3. When the test hits the break point, you should have another window open which will allow you to access your in memory db
When following above steps you find that the window hangs while the program has stopped on the break point, you may need to change your debug configuration.
In IntelliJ, in the 'Debugger' view (where from you can Resume, disable break point etc), find the 'View Breakpoints' icons (to half overlapping red circles) and click it. In the window that appears, Select to suspend only the 'Thread' instead of 'All'.
We followed this tutorial to set our test scenario for these kind of integration tests.
To access the DB while running the tests, follow the steps below
1. Add following piece of code in your @Before method
org.hsqldb.util.DatabaseManagerSwing.main(new String[] {
"--url", "jdbc:hsqldb:mem:testdb", "--noexit"
});
This will kick off a swing application which is fairly well formatted for the purpose.
2. Add a break point using you IDE and run your test in debug mode
3. When the test hits the break point, you should have another window open which will allow you to access your in memory db
When following above steps you find that the window hangs while the program has stopped on the break point, you may need to change your debug configuration.
In IntelliJ, in the 'Debugger' view (where from you can Resume, disable break point etc), find the 'View Breakpoints' icons (to half overlapping red circles) and click it. In the window that appears, Select to suspend only the 'Thread' instead of 'All'.