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

Add tests for MavenInvoker #157

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

sridamul
Copy link
Contributor

@sridamul sridamul commented Aug 5, 2024

Added a test plugin to test the Maven Invoker functions.
If there is better way to test MavenInvoker fn, let me know. Thanks!

Testing done

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

@sridamul sridamul requested a review from a team as a code owner August 5, 2024 13:16
@jonesbusy
Copy link
Collaborator

I wouldn't call maven directly from such unit tests

What about mocking Invoker invoker = new DefaultInvoker() perhaps moving it to a private member instead of local variable ?

Even if it's private it can be mocked (See https://github.com/jenkinsci/plugin-modernizer-tool/blob/main/plugin-modernizer-core/src/test/java/io/jenkins/tools/pluginmodernizer/core/github/GHServiceTest.java#L72)

So the invoker.execute(request); can be mocked and asserting the correct request (maven are are passed)

Copy link
Collaborator

@jonesbusy jonesbusy left a comment

Choose a reason for hiding this comment

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

Try mocking the Invoker class (move it as a member rather than local variable)

@jonesbusy jonesbusy marked this pull request as draft October 12, 2024 07:56
@jonesbusy
Copy link
Collaborator

Not sure if planning to work on this, but since we added Guice unit testing the MavenInvoker is probably more easy now

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.

2 participants