I'm writing tests for my repository in SpringBoot application. On production I have working MySql DB, but for testing purposes I'm trying to use H2 in-memory DB. It appears to work correctly - there are SQL queries flying in console.
The question is how I can access H2 console page while testing application. When I set a breakpoint in test method I can't access console in browser.
I tried setting up breakpoints that suspends the test thread only (no luck).
When I switch my production DB from MySql to H2, I'm able to access the console, everything works as I suspect it should. No break point is needed in opposite to tests - 'normal' application runs endlessly waiting for HTTP requests.
Simple test class I use:
@RunWith(SpringRunner.class)
@SpringBootTest()
public class StockRepositoryTest {
@Autowired
private StockRepository stockRepository;
@Test
public void Should_persist_deviceItem(){
DeviceItem deviceItem = SampleStock.s1_d1;
stockRepository.save(deviceItem);
Optional<DeviceItem> foundById = stockRepository.findById(SampleStock.s1_d1.getId());
Assert.assertTrue(foundById.isPresent());
}
I expect that when I put a break point on line in test method, while the code is suspended, I can access H2 database console and check state of data. Right now I'm not getting any response on H2 console URL (not even HTTP error code).
Thanks, regards Peter