Skip to content

Issue #84: Fixed Junit tests for WinRMCommandExecutor and WinRMInvocationHandler - #83

Merged
NassimBtk merged 2 commits into
mainfrom
fix/junit-tests-fixes
May 19, 2026
Merged

Issue #84: Fixed Junit tests for WinRMCommandExecutor and WinRMInvocationHandler#83
NassimBtk merged 2 commits into
mainfrom
fix/junit-tests-fixes

Conversation

@NassimBtk

Copy link
Copy Markdown
Collaborator

This pull request refactors and improves the unit tests for the WinRM client, primarily focusing on the WinRMInvocationHandlerTest class. The changes standardize how method invocations are mocked and verified, specifically by replacing the use of a generic mocked Method object with the actual receive method from WinRMWebService. This leads to more realistic and maintainable tests. Additionally, the changes improve clarity and robustness of exception handling in tests.

Key changes include:

Test Refactoring and Standardization

  • Replaced the use of a generic mocked Method object with the actual receive method from WinRMWebService for more accurate and meaningful unit tests. Test arguments now use realistic instances matching the receive method signature. (WinRMInvocationHandlerTest.java) [1] [2]
  • Updated all test method invocations and verifications to use the real receive method and its arguments instead of the generic METHOD and ARGS. This includes updating all doReturn, doThrow, assertEquals, assertThrows, and verify calls accordingly. (WinRMInvocationHandlerTest.java) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Helper and Utility Improvements

  • Added a helper method verifyReceiveInvoked(int times) to simplify and standardize verification of receive method invocations across tests. (WinRMInvocationHandlerTest.java)

Exception Handling and Assertions

  • Improved assertions in tests to check for exception messages using assertTrue(...startsWith(...)) for greater robustness against message changes, instead of exact matches. (WinRMInvocationHandlerTest.java) [1] [2]

Test Cleanup

  • Removed unused imports and redundant @BeforeEach setup for the mocked Method, as it is no longer needed. (WinRMInvocationHandlerTest.java) [1] [2] [3]

Minor Test Adjustments

  • Minor import additions and removals to reflect updated test logic and dependencies. (WinRMInvocationHandlerTest.java, WinRMCommandExecutorTest.java) [1] [2] [3] [4]

These changes make the tests more maintainable and realistic by using actual method signatures and arguments, and improve the clarity and reliability of test outcomes.

@NassimBtk NassimBtk changed the title Fixed Junit tests for WinRMCommandExecutor and WinRMInvocationHandler Issue #84: Fixed Junit tests for WinRMCommandExecutor and WinRMInvocationHandler May 19, 2026
@NassimBtk
NassimBtk requested a review from CherfaElyes May 19, 2026 17:33
@NassimBtk
NassimBtk merged commit 2b1bf64 into main May 19, 2026
5 checks passed
@NassimBtk
NassimBtk deleted the fix/junit-tests-fixes branch May 19, 2026 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CI fails on Linux JDK 17: Mockito state corrupted by mock(Method.class) in WinRMInvocationHandlerTest

2 participants