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
Bring JUnit Jupiter Assumptions to RequestBoundaryMethodsTest
to Avoid Test Case Quiet Quit
#2382
Bring JUnit Jupiter Assumptions to RequestBoundaryMethodsTest
to Avoid Test Case Quiet Quit
#2382
Conversation
…d Test Case Quiet Quit
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2382 +/- ##
============================================
- Coverage 50.03% 49.83% -0.20%
- Complexity 3785 3822 +37
============================================
Files 143 145 +2
Lines 33204 33360 +156
Branches 5629 5654 +25
============================================
+ Hits 16613 16625 +12
- Misses 14207 14368 +161
+ Partials 2384 2367 -17 ☔ View full report in Codecov by Sentry. |
src/test/java/com/microsoft/sqlserver/jdbc/connection/RequestBoundaryMethodsTest.java
Outdated
Show resolved
Hide resolved
2dbd726
…oundaryMethodsTest.java Co-authored-by: Jeff Wasty <v-jeffwasty@microsoft.com>
Resolve #2359
Is your feature request related to a problem? If so, please give a short summary of the problem and how the feature would resolve it
When I am go through the test class
RequestBoundaryMethodsTest
, I noticed that many of the test cases in this test class is using the if condition to determine if a test should proceed based on certain preconditions.Here is an example from
testWarnings
:This approach can lead to tests passing under conditions where they're not actually validating the intended functionality.
As I checked, all these test cases shared this design pattern in the
RequestBoundaryMethodsTest
:testModifiableConnectionProperties
testWarnings
testOpenTransactions
testStatements
testThreads
Describe the preferred solution
I would like to propose we adopt the JUnit Jupiter's assumption API to handle such precondition checks. The assumption API allows tests to be skipped when certain conditions are not met, making it clear that the test result is not applicable under those conditions. So here we can use the assumption api to replace the
if
condition without quiet quit. (If the assumption is false the TestAbortedException will be recorded).For instance, the
testWarnings
case can be refactored as follows:This change will make test results more accurately reflect the behavior being tested, as irrelevant tests are skipped rather than falsely passing.
PR Implementation
The change will be straightforward and involves replacing if statements with Assume.assumeTrue in all five test cases.
Reference Documentations/Specifications
Junit5 Assumption Doc