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 test for PropertyBasedJobInclusionStrategy class #420

Merged

Conversation

yashpal2104
Copy link
Contributor

Testing done

Add test for PropertyBasedJobInclusionStrategy class

Fixes JIRA issue JENKINS-69757

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

@yashpal2104 yashpal2104 requested a review from a team as a code owner December 28, 2024 09:53
@github-actions github-actions bot added the tests Automated test addition or improvement label Dec 28, 2024
yashpal2104 and others added 5 commits December 28, 2024 15:24
Added a constructor to initialize description, priority, and jobGroupStrategy fields.
This change allows creating JobGroup instances with specific values for these fields.
Do not use wildcard import of org.junit.Assert because that includes the
deprecated assertThat method.  Use the assertThat method from hamcrest
because it is not deprecated and works very well with hamcrest assertions.

Name the strategy uniquely for each test by including the test name in
the strategy name.  The TestName Rule is a very handy way to assure that
test data is unique for each test method without needing to worry about
the uniqueness directly.

Split the Before methods so that they can be named more specifically.
Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

I've added several assertions to the test class. I'll need to give more thought to the addition of public constructors for test purposes. I think that we might be able to move the test class so that it could use a package protected constructor. However, that needs more time.

@yashpal2104
Copy link
Contributor Author

Alright, what suits the best will work. I thought of making this a draft PR but yeah I thought the changes were valid should we make this a draft PR or is there something else we need to do?

Don't need a new constructor when setters are already available for all
the attributes used in the new constructor.
Reduce the amount of change in the production object by not creating a
new method that overrides the method from the superclass.

Limit the accessibility of the new method so that it is package protected
and not available to classes outside its own package.

Remove two duplicated test methods
@MarkEWaite
Copy link
Contributor

@yashpal2104 I've modified the class in src/main so that it is no longer providing a public method. That felt too invasive for a test related change. I've created a package protected method that is called from the test. Because it is package protected, it is only available to classes that are in the same package.

If those changes are acceptable to you, then I believe this is ready to merge. If they aren't acceptable, you are welcome to revert them or submit additional changes to further improve them.

…tegy

- Added detailed Javadoc comments for `getThisDescriptor` and `getDescriptor` methods.
- Enhanced inline comments to clarify the use of `@SuppressWarnings("unchecked")`.
@yashpal2104
Copy link
Contributor Author

Looks good to me for now. I have added some comments to the changes we made so that we can pinpoint any issues if something goes wrong. If you think this is unnecessary you can remove them.

@MarkEWaite MarkEWaite enabled auto-merge (squash) December 30, 2024 13:41
@MarkEWaite MarkEWaite merged commit 3f3fe0b into jenkinsci:master Dec 30, 2024
18 checks passed
@yashpal2104 yashpal2104 deleted the propertyBasedJobInclusionStrategyTest branch December 30, 2024 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants