We should upgrade to JUnit 5 because it's the latest and greatest version of JUnit and JHipster is hip!
Show Java developers the latest and greatest technologies.
For Maven, exclude junit:junit and include junit-jupiter-engine:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
For Gradle:
testImplementation ("org.springframework.boot:spring-boot-starter-test") {
exclude module: "junit"
exclude group: "com.vaadin.external.google", module: "android-json"
}
testImplementation "org.junit.jupiter:junit-jupiter-engine"
In .java files:
org.junit.Before with org.junit.jupiter.api.BeforeEach (or BeforeAll, I'm not sure which)org.junit.Test with org.junit.jupiter.api.Testimport org.junit.runner.RunWith;import org.springframework.test.context.junit4.SpringRunner;@RunWith(SpringRunner.class)I'm sure there's more, but this seems like the basics to get started.
That would be great. I just hope all our test dependencies work with it. For instance I had issues on a project with the EmbeddedKafka. Testcontainers seems to have an extension.
We could also use the vintage engine first and migrate all tests step by step to junit 5
I think it's better to do it in one go as users are going to be annoyed to have an app that is partially migrated between JUnit 4 and 5.
We should document how to run and use junit 4 tests, as e.g. spock currently still requires junit 4. Is someone working on this by the way already?
@atomfrede Is there a component that requires Spock in JHipster?
No there is not, so only a problem for users wanting to use it. So if no one is working on it yet I can do it.
@atomfrede did you start to work on this? I'd be happy to do it, may I assign it to myself?
No nothing substantial. Just tried a sample app with junit 5 but nothing regarding the generator. So go ahead!
Bug bounty claimed: https://opencollective.com/generator-jhipster/expenses/8820
Most helpful comment
I think it's better to do it in one go as users are going to be annoyed to have an app that is partially migrated between JUnit 4 and 5.