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 JobInclusionFolderProperty class #416

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

yashpal2104
Copy link
Contributor

Testing done

Added a new test class for JobInclusionFolderProperty class and added a constructor in ItemInfo class.

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 27, 2024 13:24
@github-actions github-actions bot added dependencies Dependency related change tests Automated test addition or improvement labels Dec 27, 2024
* add tests for util class

* Use JUnit 4 assertions with JUnit 4 tests

---------

Co-authored-by: Mark Waite <[email protected]>
@yashpal2104
Copy link
Contributor Author

@MarkEWaite I can modify these tests to isolate tests by creating a new FreeStyleProject before each test to execute? If resource usage is a concern, otherwise creating new project it ensures test isolation and prevents side effects from shared state and maintaining test reliability and accuracy. That is why I have left a tearDown() method in the class if at any point in future if anyone considers this approach more reliable?

@MarkEWaite MarkEWaite removed the dependencies Dependency related change label Dec 28, 2024
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.

The output when I run those tests locally includes a null pointer exception that is not causing the test to fail. I don't see the null pointer exception in the output from ci.jenkins.io but I see it locally. That will need to be resolved before this pull request can be considered further. The null pointer exception message that I see is:

java.lang.NullPointerException: Cannot invoke "java.util.List.add(Object)" because "jenkins.advancedqueue.testutil.TestRunListener.actual" is null
	at jenkins.advancedqueue.testutil.TestRunListener.onStarted(TestRunListener.java:33)
	at hudson.model.listeners.RunListener.lambda$fireStarted$2(RunListener.java:246)
	at jenkins.util.Listeners.lambda$notify$0(Listeners.java:59)
	at jenkins.util.Listeners.notify(Listeners.java:67)
	at hudson.model.listeners.RunListener.fireStarted(RunListener.java:244)
	at hudson.model.Run.execute(Run.java:1892)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)

@yashpal2104
Copy link
Contributor Author

The output when I run those tests locally includes a null pointer exception that is not causing the test to fail. I don't see the null pointer exception in the output from ci.jenkins.io but I see it locally. That will need to be resolved before this pull request can be considered further. The null pointer exception message that I see is:

java.lang.NullPointerException: Cannot invoke "java.util.List.add(Object)" because "jenkins.advancedqueue.testutil.TestRunListener.actual" is null
	at jenkins.advancedqueue.testutil.TestRunListener.onStarted(TestRunListener.java:33)
	at hudson.model.listeners.RunListener.lambda$fireStarted$2(RunListener.java:246)
	at jenkins.util.Listeners.lambda$notify$0(Listeners.java:59)
	at jenkins.util.Listeners.notify(Listeners.java:67)
	at hudson.model.listeners.RunListener.fireStarted(RunListener.java:244)
	at hudson.model.Run.execute(Run.java:1892)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)

I did get that error locally but after (hours of) some modifications it disappeared so yes I don't have a solution right now I will get to it as it is occurring now

@MarkEWaite
Copy link
Contributor

Null pointer exception is fixed as far as I can tell.

@MarkEWaite MarkEWaite changed the title Add test for JobInclusionFolderProperty class and a constructor in ItemInfo class Add test for JobInclusionFolderProperty class Dec 28, 2024
@yashpal2104
Copy link
Contributor Author

Thank you for helping out, I think I should n't have tried to change the methods in the class excuse me this time I did try something out and it didn't work out.

@MarkEWaite
Copy link
Contributor

MarkEWaite commented Dec 28, 2024

Thank you for helping out, I think I should n't have tried to change the methods in the class excuse me this time I did try something out and it didn't work out.

No problem. I'm truly pleased that you are exploring and that you're not shy about making changes that improve testability.

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.

3 participants