Skip to content

[All] Use Jupiter Assertions over JUnit4 Assert #1935

New issue

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

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

Already on GitHub? # to your account

Merged
merged 6 commits into from
Apr 5, 2020

Conversation

timtebeek
Copy link
Contributor

@timtebeek timtebeek commented Apr 3, 2020

Summary

Use Jupiter Assertions over JUnit4 Assert. In particular deltaspike seems to have had a few old style Asserts. Jupiter should be preferred where possible, unless we're verifying compatibility such as in the junit module.

Types of changes

  • Bug fix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).

Checklist:

  • I've added tests for my code.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@timtebeek timtebeek self-assigned this Apr 3, 2020
@timtebeek
Copy link
Contributor Author

@mpkorstanje wrote myself a script yesterday to convert some work projects from JUnit4 to Jupiter; thought it couldn't hurt to run it on cucumber-jvm as well. Is it worth trying to make this work by changing the archetype dependencies to use jupiter?

@mpkorstanje
Copy link
Contributor

Is it worth trying to make this work by changing the archetype dependencies to use jupiter?

Not yet. The archetype is used in our documentation as part of the 10-minute tutorial. The tutorial is aimed at extremely new developers. There is little very tolerance for platform and tooling related problems and tooling support for Junit Platform hasn't quite reached the point yet where I'd be comfortable changing that.

Internally Surefire, Gradle assume the old class based execution model. This means that Cucumber works less then stellar with these integrations. So I'm currently waiting for a few issues to be resolved here:

With respect to IDEA, there is no good way to use the JUnit Platform to run individual scenarios and so I'm waiting for:

You may find some enjoyment in trying solve junit-team/junit5#2146. JUnit 5s code base has amazing quality.

@mpkorstanje
Copy link
Contributor

I wrote myself a script yesterday to convert some work projects from JUnit4 to Jupiter;

This should also picks up the Spring related @RunWith annotations.

https://github.com/sbrannen/junit-converters

@timtebeek
Copy link
Contributor Author

I wrote myself a script yesterday to convert some work projects from JUnit4 to Jupiter;

This should also picks up the Spring related @RunWith annotations.

https://github.com/sbrannen/junit-converters

Yes thanks; I had seen you star that repository a while back ; I adapted a bit from that yesterday, eventually ending up with: https://gist.github.com/timtebeek/51d0988397b9e9deac9a018d297e88d5

Some of it is a bit specific to the job, and it's not the cleanest code, but it gets the job done.

@timtebeek
Copy link
Contributor Author

Is it worth trying to make this work by changing the archetype dependencies to use jupiter?

Not yet. The archetype is used in our documentation as part of the 10-minute tutorial. The tutorial is aimed at extremely new developers. There is little very tolerance for platform and tooling related problems and tooling support for Junit Platform hasn't quite reached the point yet where I'd be comfortable changing that.

Understandable; if I take out the archetype changes we're left with changes in deltaspike, an possibly some in spring/src/test/java/io/cucumber/spring/contextcaching/SomeTest.java which doesn't yet use the new CucumberContextConfiguration; should I distill this PR down to just those changes?

Diving into JUnit5 might seem fun, but not sure if I'll find the time easily; also, the package access challenge posed in the issue you raised does not seem to have a clear resolve yet. I'll explore if I find time. :)

@mpkorstanje
Copy link
Contributor

Sure every bit helps!

@timtebeek
Copy link
Contributor Author

@mpkorstanje Deltaspike changes ready for review/merge now then. :)

@coveralls
Copy link

coveralls commented Apr 5, 2020

Coverage Status

Coverage remained the same at 86.329% when pulling badfed3 on use-jupiter-assertions into 8917f3e on master.

@mpkorstanje mpkorstanje changed the title Use Jupiter Assertions over JUnit4 Assert [All] Use Jupiter Assertions over JUnit4 Assert Apr 5, 2020
@mpkorstanje mpkorstanje merged commit 78ac65a into master Apr 5, 2020
@mpkorstanje mpkorstanje deleted the use-jupiter-assertions branch April 5, 2020 16:16
@mpkorstanje
Copy link
Contributor

Cheers!

I fixed up spring too. RunWith could be replaced with ExtendsWith with no issue. I guess this may not have been quite clear given the class was named SomeTest.

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

Successfully merging this pull request may close these issues.

3 participants