Skip to content

Conversation

@strangelookingnerd
Copy link
Contributor

@strangelookingnerd strangelookingnerd commented Jan 9, 2025

Re-opened from #691

It should be considered best practice to start plugin development using JUnit5 over JUnit4.

  • org.junit.* imports being updated to JUnit5 equivalents
  • Use @WithJenkins in combination with JenkinsRule
  • Make test classes and methods package-private (convention for JUnit5)

I'm not 100% convinced that I migrated SampleConfigurationTest correctly since I was not able to find a proper equivalent for JenkinsSessionRule - maybe @basil could confirm if the test still covers the intended functionality.

Now that jenkinsci/jenkins-test-harness#716 was merged there is a clean way to implement SampleConfigurationTest.java with JUnit5.

Creating this as a draft, since it depends on plugin pom after 5.5, which required to bump the jenkins.baseline to 2.479.x. Any feedback is highly welcome.

Testing done

Ran mvn clean verify without errors.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@timja
Copy link
Member

timja commented Jan 13, 2025

Creating this as a draft, since it depends on plugin pom after 5.5, which required to bump the jenkins.baseline to 2.479.x. Any feedback is highly welcome.

I think its fine to bump, better that new plugins are on the EE 9. We sometimes bump this default earlier than the general plugin one if there's a reason to.

@strangelookingnerd strangelookingnerd marked this pull request as ready for review January 13, 2025 08:55
@strangelookingnerd
Copy link
Contributor Author

I think its fine to bump, better that new plugins are on the EE 9.

100% agree.

@timja timja merged commit c25bca8 into jenkinsci:master Jan 13, 2025
2 checks passed
@strangelookingnerd strangelookingnerd deleted the feature/upgrade_to_junit5 branch January 13, 2025 09:00
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.452</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.4</jenkins.version>
<jenkins.baseline>2.479</jenkins.baseline>
Copy link
Member

Choose a reason for hiding this comment

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

Incomplete ⇨ #788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants