For a JavaEE project with working JUnit 5 tests I decided to give ActiveJDBC a try. Unfortunately I implemented all the tests with JUnit 5 before this decision so I have to update my tests for the usage with ActiveJDBC and was wondering why they won't get the test-db connection out of the database.properties file when extending the class with 'DBSpec' and just throw an DBException when using JUnit version 5 instead of version 4:
org.javalite.activejdbc.DBException: Failed to retrieve metadata from DB, connection: 'default' is not available
JUnit 5 - test
import org.javalite.activejdbc.test.DBSpec;
import org.junit.jupiter.api.Test;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
public class MyModelTest extends DBSpec {
//Test will fail with DBException
@Test
public void one() {
MyModel model = new MyModel();
a(model).shouldBe("valid");
}
}
JUnit 5 - dependencies
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.3.0</version>
<scope>test</scope>
</dependency>
When i switch to JUnit 4, everything works as expected
JUnit 4 - test
import org.javalite.activejdbc.test.DBSpec;
import org.junit.Test;
public class MyModelTest extends DBSpec {
//Test will pass
@Test
public void one() {
MyModel model= new MyModel();
a(model).shouldBe("valid");
}
}
JUnit 4 - dependencies
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
It won't be that much of a deal to just 'rewrite' my tests for JUnit4 but are there any plans to support JUnit5 in the near future?
You are correct, JUnit5 is not supported yet. We filed a new issue: https://github.com/javalite/activejdbc/issues/784 to add support for it. Please, track it to see when the next snapshot will be available.