Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to JUnit 5 #9498

Closed
mraible opened this issue Mar 28, 2019 · 8 comments

Comments

Projects
None yet
7 participants
@mraible
Copy link
Contributor

commented Mar 28, 2019

Overview of the feature request

We should upgrade to JUnit 5 because it's the latest and greatest version of JUnit and JHipster is hip!

Motivation for or Use Case

Show Java developers the latest and greatest technologies.

How

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:

  1. Replace org.junit.Before with org.junit.jupiter.api.BeforeEach (or BeforeAll, I'm not sure which)
  2. Replace org.junit.Test with org.junit.jupiter.api.Test
  3. Remove classes and imports no longer needed:
    1. import org.junit.runner.RunWith;
    2. import org.springframework.test.context.junit4.SpringRunner;
    3. @RunWith(SpringRunner.class)

I'm sure there's more, but this seems like the basics to get started.

@cbornet

This comment has been minimized.

Copy link
Member

commented Mar 28, 2019

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.

@atomfrede

This comment has been minimized.

Copy link
Member

commented Apr 3, 2019

We could also use the vintage engine first and migrate all tests step by step to junit 5

@PierreBesson

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2019

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.

@atomfrede

This comment has been minimized.

Copy link
Member

commented Apr 10, 2019

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?

@mraible

This comment has been minimized.

Copy link
Contributor Author

commented Apr 15, 2019

@atomfrede Is there a component that requires Spock in JHipster?

@jdubois jdubois added the $100 label Apr 15, 2019

@atomfrede

This comment has been minimized.

Copy link
Member

commented Apr 15, 2019

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.

@hdurix

This comment has been minimized.

Copy link
Member

commented Apr 20, 2019

@atomfrede did you start to work on this? I'd be happy to do it, may I assign it to myself?

@atomfrede

This comment has been minimized.

Copy link
Member

commented Apr 20, 2019

No nothing substantial. Just tried a sample app with junit 5 but nothing regarding the generator. So go ahead!

@hdurix hdurix self-assigned this Apr 20, 2019

hdurix added a commit to hdurix/generator-jhipster that referenced this issue Apr 20, 2019

@hdurix hdurix referenced this issue Apr 20, 2019

Merged

Upgrade to JUnit 5 #9590

3 of 4 tasks complete

hdurix added a commit to hdurix/generator-jhipster that referenced this issue Apr 20, 2019

@jdubois jdubois added this to the 6.0.0 milestone May 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.