Skip to content

Conversation

@lutovich
Copy link
Contributor

@lutovich lutovich commented Jul 27, 2021

Main changes:

  • all tests use JUnit Jupiter APIs and assertions
  • remove public modifiers from test classes and test methods because they are unnecessary with JUnit Jupiter
  • replace JVM version assumptions with @EnabledOnJre annotations that support version ranges
  • replace OS assumptions with @EnabledOnOs and @DisabledOnOs
  • replace JUnit 4 categories with JUnit 5 tags for Black, Clang, Npm tests. See com.diffplug.spotless.tag package
  • enable JUnit Jupiter in Gradle build scripts for the test task with useJUnitPlatform()

@nedtwigg
Copy link
Member

nedtwigg commented Jul 27, 2021

WIP looks great, plan looks good too.

@lutovich lutovich force-pushed the junit5 branch 8 times, most recently from 428d457 to a93cf1a Compare September 14, 2021 21:15
}
}
@EnabledForJreRange(min = JAVA_11)
abstract class EclipseWtpFormatterCommonTests extends EclipseCommonTests {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not find a good way to combine parametrization with test inheritance in JUnit 5. That's why I split this test class into:

  • EclipseWtpFormatterCssTest
  • EclipseWtpFormatterHtmlTest
  • EclipseWtpFormatterJsonTest
  • EclipseWtpFormatterJsTest
  • EclipseWtpFormatterXmlTest

separate test classes. Each class defines language-specific input and test expectation. Separate test classes replace the WTP enum.

I also effectively removed EclipseWtpFormatterStepTestOld because of the same reason. Method #getSupportedVersions() now returns both old and new versions in a single array.

Does this seem like a sensible approach? Suggestions are much appreciated

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old stuff looks better, but the new stuff isn't bad. Adopting JUnit 5 is quite nice, and I think it's worth merging this quickly to avoid conflicts. Can always refactor back together in the future. This okay with you @fvgh?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dug into this a bit more and made a small change in f35a109. I think we're now testing everything that we tested before, and we should be good to go, but I'd still like @fvgh to sign-off first. Wanna press the merge button @fvgh when/if you're okay with this test change?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A little overhead having so many test classes, but it is readable.
@lutovich Thanks for putting in so much effort. I always missed JUnit5 functionality.

Main changes:
 * all tests use JUnit Jupiter APIs and assertions
 * remove public modifiers from test classes and test methods because they are
   unnecessary with JUnit Jupiter
 * replace JVM version assumptions with `@EnabledOnJre` annotations that
   support version ranges
 * replace OS assumptions with `@EnabledOnOs` and `@DisabledOnOs`
 * enable JUnit Jupiter in Gradle build scripts for the test task
   with `useJUnitPlatform()`
@nedtwigg
Copy link
Member

I vote for pushing new commits, rather than squashing every time. We can squash in final merge, but hard to follow/review progress if every new push is a squash.

@lutovich
Copy link
Contributor Author

@nedtwigg sorry, I did not realize you were reviewing. I was re-reviewing myself and making some minor tweaks. Also, added a better commit message. PR is ready for review now.

@lutovich lutovich marked this pull request as ready for review September 15, 2021 22:12
@lutovich lutovich requested a review from a team September 15, 2021 22:13
… previous behavior of EclipseWtpFormatterStepTest vs EclipseWtpFormatterStepTestOld.
Copy link
Member

@nedtwigg nedtwigg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the Circle CI test results:

  • test_windows: 255 -> 245
  • test_npm_8: broken before and after this PR, test results not getting parsed :(
  • test_windows, test_nomaven_15, test_nomaven_11: 255 -> 245
  • test_justmaven_11: 72 -> 72

So all tests are still there and passing except for 10, which comes from:

  • lost EclipseWtpFormatterStepTestOld x10
  • lost EclipseWtpFormatterStepTest x10
  • added x10 from EclipseWtpFormatter[Blah]Test

The difference is that EclipseWtpFormatterStepTestOld ran on all JRE, whereas non-old required JRE11 or later. So all tests are accounted for, and I think this is ready to merge!

@nedtwigg nedtwigg merged commit 6f45df7 into diffplug:main Sep 16, 2021
@nedtwigg
Copy link
Member

Thanks a ton @lutovich, that was a lot of work!

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 this pull request may close these issues.

3 participants