-
Notifications
You must be signed in to change notification settings - Fork 59
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
Improve Automated Test Coverage #366
Improve Automated Test Coverage #366
Conversation
Signed-off-by: shinigami-777 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the effort to increase test coverage, but there is so much use of mock objects that it reduces the value of the test. Based on the token-macro source code, there should not be a need to use mock objects for the test.
...g/jvnet/jenkins/plugins/nodelabelparameter/parameterizedtrigger/NodeLabelBuildParameter.java
Outdated
Show resolved
Hide resolved
...g/jvnet/jenkins/plugins/nodelabelparameter/parameterizedtrigger/NodeLabelBuildParameter.java
Outdated
Show resolved
Hide resolved
...net/jenkins/plugins/nodelabelparameter/parameterizedtrigger/NodeLabelBuildParameterTest.java
Outdated
Show resolved
Hide resolved
Signed-off-by: shinigami-777 <[email protected]>
Yes I looked at the TokenMacro source code and found the string to cause the exception without mocking. Thanks a lot for suggesting. |
Simpler expression fails evaluation without embedded newlines
Running the build and asserting that it was successful provides a workspace and tests a little more of the code than if we construct a build ourselves.
The hamcrest matchers provide clearer error messages when an assertion fails. The clearer error message makes it easier to diagnose failures. The earlier change to run the build and wait for it to complete successfully also changed the details of the exception being thrown. Assert that the expected exception message is found in the log.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks very much! Your test implementation looks very good. I adapted it with some additions that I found while exploring the test from inside a debugger. Specific details of each change are embedded in the commit comments for each of the commits:
- 49c5d38 - simplify the node label expression
- 0ab1ada - use a non-deprecated StreamTaskListener constructor
- 3ac804e - run the build and assert that it passes
- e479792 - use hamcrest matchers for better failure messages
Hopefully you're OK with my changes. I plan to merge this as soon as the CI checks pass.
This is part of JENKINS-69756.
Added test for
NodeLabelBuildParameter
class specifically covering theMacroEvaluationException
case in thegetAction
method.Test coverage before:
Test coverage after:
Submitter checklist