-
Notifications
You must be signed in to change notification settings - Fork 74
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 test for SorterStrategyDescriptor class #429
Add test for SorterStrategyDescriptor class #429
Conversation
@MarkEWaite |
The spotbugs annotation is used in the declaration of the method so should be used in this implementation.
Individual tests do not need the cost or time delay of starting a new Jenkins controller.
Allocate a strategy and test its descriptor
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.
The technique looks good to me. I've submitted a few changes and corrections.
import hudson.model.FreeStyleBuild; | ||
import hudson.model.FreeStyleProject; | ||
import hudson.model.Queue; | ||
import org.jetbrains.annotations.NotNull; |
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.
We use spotbugs annotations for nullability rather than JetBrains annotations
import org.jetbrains.annotations.NotNull; | |
import edu.umd.cs.findbugs.annotations.NonNull; |
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.
Yes I think this was because I was using Intellij Jetbrains IDE, I mistakenly imported the incorrect one
|
||
private static class TestSorterStrategy extends SorterStrategy { | ||
@Override | ||
public SorterStrategyCallback onNewItem(@NotNull Queue.Item item, SorterStrategyCallback weightCallback) { |
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.
Spotbugs annotation rather than JetBrains annotation
public SorterStrategyCallback onNewItem(@NotNull Queue.Item item, SorterStrategyCallback weightCallback) { | |
public SorterStrategyCallback onNewItem(@NonNull Queue.Item item, SorterStrategyCallback weightCallback) { |
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 correcting this
Other tests will fail if descriptor is null
Thanks for reviewing the PR @MarkEWaite . |
Changes to the main classes are acceptable if they are:
In the case of MultiBucketStrategy, why not focus on testing AbsoluteStrategy, since it extends MultiBucketStrategy?
I suspect you may have been making a mistake in that case. Generally you should not need to add to the plugin pom file unless the addition is test scoped and specific to that test. |
Alright, I will try this instead
Ok I was only thinking of using that wrapper class for only specific test class only but a error of not having XStream-Core and a fix was provided by the IDE was to add this dependency link |
XStream is already provided by Jenkins core. There should never be a need to add it to a plugin pom. |
Testing done
Add test for SorterStrategyDescriptor class
Aims to Fix JENKINS-69757
Submitter checklist