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

Update created build.gradle to use Junit 5.6.3+ so that existing team JUnit4 tests still function #4826

Closed
fovea1959 opened this issue Dec 16, 2022 · 2 comments · Fixed by wpilibsuite/vscode-wpilib#568

Comments

@fovea1959
Copy link
Contributor

Is your feature request related to a problem? Please describe.
We have existing libraries from previous years that have JUnit4 tests. 2023 beta-6 generates the following snippet of build.gradle:

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
    testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'

We would prefer not to rewrite our JUnit4 tests, so we want to use org.junit.vintage:junit-vintage-engine to run our old tests:

    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.2'
    testImplementation 'org.junit.jupiter:junit-jupiter-params:5.4.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'

    testImplementation("junit:junit:4.13.2")
    testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.4.2") {
        because 'allows JUnit 3 and JUnit 4 tests to run'
    }

However, builds fail with:

org.gradle.api.internal.tasks.testing.TestSuiteExecutionException: Could not complete execution for Gradle Test Executor 1.
        ...traceback...
Caused by: org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-vintage' failed to discover tests
        ...traceback...
Caused by: org.junit.platform.commons.JUnitException: Failed to parse version of junit:junit: 4.13.2

Research reveals that versions of JUnit 5 prior to 5.6.3 have this issue. Ref: https://stackoverflow.com/a/67566548/17887564 and
junit-team/junit5#2198.

Describe the solution you'd like
Have "Create Project" generate a build.gradle with references to JUnit 5.6.3(+).

Describe alternatives you've considered
Our alternatives are to simply fix the versions in build.gradle whenever we have a project with tests, or rewrite our tests for JUnit5 (straightforward, but time consuming)

Additional context
It appears that the build for wpilibj itself uses JUnit 5.8.2 (ref: https://github.com/wpilibsuite/allwpilib/blob/main/shared/java/javacommon.gradle#L115, so apparently it's trustworthy?

@rzblue
Copy link
Member

rzblue commented Dec 16, 2022

You can remove the dependencies for junit 5 and replace with junit 4, or whatever other test suite you'd like to use- they are there as a convenience for teams.

You can also update to whatever junit version you want.

@Starlight220
Copy link
Member

I don't see a reason not to upgrade for the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants