I wrote several JUnit test classes, in a maven project that uses JDBC to connect to a h2 database. I have 8 test classes.
- When I run
All tests
with IntelliJ, I have a JDBC error (on the last test class : WorkspaceTest.java):
org.h2.jdbc.JdbcSQLException: Table "WORKSPACE" not found; SQL statement:
(if you want the full trace, I'll put it, but it's kinda long).
note : All the 7 other test classes are passed.
When I run each test separately with IntelliJ, they all pass, 1 by 1.
When I run the tests with
mvn clean install
, i get a build failure, with the error (on the last test class : OWSContextTest.java):
update(org.orbisgis.server.mapcatalog.OWSContextTest): Table "FOLDER" not found; SQL statement:
note : All the 7 other test classes are passed.
- When I run this test alone with mvn (
mvn -Dtest=OWSContextTest test
), the test passes.
The tests classes are supposed to be independent, as in each of them I have a @BeforeClass
which drops the database, then creates it, and finally populates it, AND a @AfterClass
which drops the database.
If you need anything else, I'll edit for it. I really have no clue whatsoever about the reason to this behavior.
Thanks for your help.
EDIT : I just ran All tests
about 10 times on IntelliJ, and it worked about 6 times, and failed with the same error 4 times. Don't know if I can really trust intelliJ test mechanism tho.
EDIT2 : If it can help, I tried more things : I ran 7 out of my 8 tests classes, for all 8 ones (I ran 1 2 3 4 5 6 7 together, then 2 3 4 5 6 7 8 together, then ...) And they all passed (all combination of 7 out of 8)