eas5 opened a new pull request #652:
URL: https://github.com/apache/jmeter/pull/652


   This is a test refactoring.
   
   **Problem:**
   The Exception Handling test smell occurs when the test outcome is manually 
determined through pass or fail method calls, which are dependent on the 
production method throwing an exception, generally inside a try/catch block.
   
   **Solution:**
   We propose using JUnit's exception handling to automatically pass/fail the 
test instead of writing custom exception handling code or throwing an 
exception. In this particular case, JUnit 5 assertThrows() was used to properly 
handle the expected exception.
   
   **Result:**
   _Before:_
   ```
   try {
       xb.closeTag("abcd");
       fail("Should have caused IllegalArgumentException");
   } catch (IllegalArgumentException e) {
   }
   ```
   
   _After:_
   ```
   assertThrows(IllegalArgumentException.class, () -> {
       xb.closeTag("abcd");
   });
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to