-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Fix array assertEquals failure message when an element is null or non-null #3136
Fix array assertEquals failure message when an element is null or non-null #3136
Conversation
WalkthroughThe update focuses on enhancing the Changes
Sequence Diagram(s)Changes are mainly related to improving messages and adding tests. Sequence diagrams are omitted for simplicity. Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- CHANGES.txt (1 hunks)
- testng-asserts/src/main/java/org/testng/Assert.java (1 hunks)
- testng-asserts/src/test/java/org/testng/AssertTest.java (1 hunks)
Files skipped from review due to trivial changes (1)
- testng-asserts/src/main/java/org/testng/Assert.java
Additional comments not posted (4)
testng-asserts/src/test/java/org/testng/AssertTest.java (3)
358-365
: Excellent use ofexpectedExceptions
andexpectedExceptionsMessageRegExp
to validate the error message format. This aligns well with the PR's objectives to enhance error messages in array assertions.
367-374
: Well implemented test to check assertions when expected non-null elements are null. The detailed assertion message validation ensures clarity in error reporting, which is crucial for debugging.
376-383
: This test effectively captures the scenario where an expected null element is non-null, ensuring that the failure message accurately reflects the discrepancy at the correct array index.CHANGES.txt (1)
4-4
: Ensure that the description for the fix in the change log is accurate and matches the implemented changes in the PR.Verification successful
The search results show multiple instances of the
failNotEquals
method in bothAssertJUnit.java
andAssert.java
. However, the context provided does not clearly indicate any specific changes related to handling array elements and their indices.To ensure the accuracy of the change log description, it is necessary to further investigate the context around array-specific assertions and see if there are any modifications or additions that handle array elements and their indices.
The additional context around the
assertArrayEquals
andassertArrayNotEquals
methods inAssert.java
shows that there are indeed mechanisms in place to handle array assertions and provide detailed messages, including information about array indices.This matches the description in the change log entry:
Fixed: GITHUB-3135: assertEquals on arrays - Failure message is missing information about the array index when an array element is unexpectedly null or non-null (Albert Choi)
The implementation includes logic to generate detailed error messages that mention array indices when elements do not match, which aligns with the change log description.
- : The change log description accurately reflects the implemented changes related to array assertions and detailed failure messages.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the accuracy of change log description with the actual code changes. # Test: Search for the function `failNotEquals` and check the parameter name change. rg --type java $'failNotEquals'Length of output: 1993
Script:
#!/bin/bash # Extract relevant code around `failNotEquals` in `AssertJUnit.java` and `Assert.java` to verify changes. # Display lines around `failNotEquals` in `AssertJUnit.java` rg --type java --context 5 'failNotEquals' testng-core/src/main/java/org/testng/AssertJUnit.java # Display lines around `failNotEquals` in `Assert.java` rg --type java --context 5 'failNotEquals' testng-asserts/src/main/java/org/testng/Assert.javaLength of output: 6066
Script:
#!/bin/bash # Further investigate the context around array-specific assertions to verify changes related to array elements and their indices. # Display lines around `assertArrayEquals` and `assertArrayNotEquals` in `Assert.java` rg --type java --context 10 'assertArrayEquals|assertArrayNotEquals' testng-asserts/src/main/java/org/testng/Assert.javaLength of output: 2628
Fixes #3135 - assertEquals on arrays - Failure message is missing information about the array index when an array element is unexpectedly null or non-null.
Just need to use the
errorMessage
variable instead ofmessage
.Did you remember to?
CHANGES.txt
./gradlew autostyleApply
We encourage pull requests that:
If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.
Note: For more information on contribution guidelines please make sure you refer our Contributing section for detailed set of steps.
Summary by CodeRabbit
Bug Fixes
assertEquals
on arrays to provide clearer information when an array element is unexpectedly null or non-null.Tests