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

Enable using @LocalData for JUnit5 tests #900

Merged

Conversation

strangelookingnerd
Copy link
Contributor

Right now there seems to be no way to make JUnit5 tests annotated with @LocalData to resolve the local data in a convenient way.
This PR adds support by adapting the recipe resolution in org.jvnet.hudson.test.junit.jupiter.JUnit5JenkinsRule#recipe as well as the test method resolution in org.jvnet.hudson.test.recipes.LocalData.RuleRunnerImpl#setup.

This change enables more tests to migrate to JUnit5

Testing done

Added 4 new tests that demonstrate the correct resolution of @LocalData in JUnit5 tests,

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

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Thanks!

@timja timja merged commit 446201c into jenkinsci:master Jan 20, 2025
15 checks passed
@strangelookingnerd strangelookingnerd deleted the enable_local_data_for_junit5 branch January 20, 2025 16:31
Vlatombe added a commit to Vlatombe/jenkins-test-harness that referenced this pull request Jan 23, 2025
By switching to `getDeclaredMethod` in jenkinsci#900, this broke this use case
that is currently exercised in email-ext plugin
(`ScriptContentSecureTest>ScriptContentTest#testTemplateShouldBeLoadedFromTheClosestExistingFolderConfigInTheHierarchyUpToGlobalConfig`)
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.

2 participants