starting and stopping hsqldb from unit tests

后端 未结 6 799
清歌不尽
清歌不尽 2021-01-21 04:07

I\'m trying to create integration tests using hsqldb in an in memory mode. At the moment, I have to start the hsqldb server from the command line before running the unit tests.

6条回答
  •  感情败类
    2021-01-21 04:48

    What about starting server through Runtime.getRuntime().exec("shell command here")? You have to do it only once for all tests, so it won't add too big lag.

    Update
    Ok, looks like you've solved it yourself :)

    Update 2
    To execute some code once before (or after) unit tests, you can

    static class TestWrapper extends TestSetup {
        TestWrapper(TestSuite suite) {
            super(suite);
        }
    
        protected void setUp() throws Exception {
            // start db
        }
    
        protected void tearDown() throws Exception {
            // kill db
        }
    }
    

    Then, just wrap your test set in it: new TestWrapper(suite)

提交回复
热议问题