Skip to content

Conversation

strangelookingnerd
Copy link
Contributor

This PR aims to migrate all tests to JUnit5. Changes include:

  • Migrate annotations and imports
  • Migrate assertions
  • Remove public visibility for test classes and methods
  • Minor clean up

I am well aware that this is a quite large changeset however I hope that there is still interest in this PR and it will be reviewed.
If there are any questions, please do not hesitate to ping me.

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 demonstrate the feature works or the issue is fixed

* Migrate annotations and imports
* Migrate assertions
* Remove public visibility for test classes and methods
* Minor code cleanup
@strangelookingnerd
Copy link
Contributor Author

For some reason ReaperTest.testStopWatchingOnCloseException is failing.

org.opentest4j.AssertionFailedError: no watcher events ==> expected: <0> but was: <2>
	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
	at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
	at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:150)
	at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:563)
	at org.csanchez.jenkins.plugins.kubernetes.pod.retention.ReaperTest$CapturingReaperListener.expectNoEvents(ReaperTest.java:855)
	at org.csanchez.jenkins.plugins.kubernetes.pod.retention.ReaperTest.testStopWatchingOnCloseException(ReaperTest.java:371)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)

I also see this test failing locally when running the class. Running the test alone however works fine. Adding await() or Thread.sleep did not help. I am kind of lost here to be honest.

@strangelookingnerd strangelookingnerd marked this pull request as ready for review August 21, 2025 08:35
@strangelookingnerd strangelookingnerd requested a review from a team as a code owner August 21, 2025 08:35
* ReaperListenerWatchEvent converted to record
* CapturingReaperListener#CAPTURED_EVENTS not static anymore. Removed Junit extension as it was not actually needed.
* Use await() instead of relying on java monitor and synchronized.
@Vlatombe
Copy link
Member

For some reason ReaperTest.testStopWatchingOnCloseException is failing.

Addressed

@Vlatombe Vlatombe added the test Tests label Aug 25, 2025
# Conflicts:
#	src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineTest.java
@Vlatombe Vlatombe enabled auto-merge (squash) September 30, 2025 07:41
ConfigMapVolume configMapVolume = new ConfigMapVolume("oneMountPath", "Myvolume", false);
configMapVolume.setSubPath("miSubpath");
assertEquals(configMapVolume.getSubPath(), "miSubpath");
assertEquals("miSubpath", configMapVolume.getSubPath());
Copy link
Member

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
test Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants