Skip to content
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 for #3189 - fixed ignored testcases count #3190

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

Kanaduchi
Copy link
Contributor

@Kanaduchi Kanaduchi commented Nov 21, 2024

Fixes #3189 .

Did you remember to?

  • Add test case(s)
  • Update CHANGES.txt
  • Auto applied styling via ./gradlew autostyleApply

We encourage pull requests that:

  • Add new features to TestNG (or)
  • Fix bugs in TestNG

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

    • Corrected the calculation of 'invocation-numbers' in test results.
    • Resolved issues with data providers affecting test outcomes.
    • Fixed execution stalls related to thread pool settings.
    • Enhanced failure messages for array assertions.
    • Corrected the count of ignored tests in XML results.
  • New Features

    • Introduced a sample class demonstrating the use of the ignore functionality in tests.
  • Tests

    • Updated test configurations and assertions to reflect new expected behaviors.

Copy link

coderabbitai bot commented Nov 21, 2024

Walkthrough

The pull request introduces various bug fixes and enhancements to the TestNG framework, particularly in version 7.11.0. Key changes include corrections to the calculation of ignored tests, improvements in the reporting of test results, and the addition of a new test class to demonstrate the ignore functionality. The modifications to the AbstractXmlReporter class ensure that the ignored count is accurately reflected, while updates to existing tests align expected outcomes with the new logic.

Changes

File Path Change Summary
CHANGES.txt Documented various bug fixes and enhancements for version 7.11.0, including fixes for ignored tests and reporting.
testng-core/src/main/java/org/testng/reporters/AbstractXmlReporter.java Modified the add method in the Count class to correctly accumulate the ignored count.
testng-core/src/test/java/test/reports/SimpleIgnoredSample.java Added a new class SimpleIgnoredSample with a test method annotated with @Ignore.
testng-core/src/test/java/test/reports/XmlReporterTest.java Updated the ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports test to reflect changes in ignored tests.

Assessment against linked issues

Objective Addressed Explanation
Correct number of ignored tests displayed in the XML results (#3189)

Possibly related PRs

  • Streamline invocation numbers in failed xml file #3181: This PR directly addresses the calculation of 'invocation-numbers' in the testng-failed.xml file, which is a key issue mentioned in the main PR's summary regarding the correction of invocation numbers when using retries and data providers.

Poem

🐰 In the garden of tests, we hop with glee,
Ignored counts fixed, as clear as can be.
With each little change, our framework grows bright,
Reporting the truth, in the day and the night.
So let’s celebrate bugs that have met their end,
In the world of TestNG, we’ll always ascend! 🌼


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
testng-core/src/test/java/test/reports/XmlReporterTest.java (1)

96-101: Consider splitting the test or updating the method name.

The test method name ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports doesn't fully reflect its current responsibility, as it now also verifies the correct counting of ignored tests with the addition of SimpleIgnoredSample.class.

Consider either:

  1. Splitting this into two separate test methods to maintain single responsibility, or
  2. Updating the method name to reflect both concerns being tested

Example of a more descriptive name if keeping as single test:

-public void ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports()
+public void ensureCorrectCountingOfSkippedConfigurationAndIgnoredTestsInXmlReports()
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 7c80f4c and fb83289.

📒 Files selected for processing (4)
  • CHANGES.txt (1 hunks)
  • testng-core/src/main/java/org/testng/reporters/AbstractXmlReporter.java (1 hunks)
  • testng-core/src/test/java/test/reports/SimpleIgnoredSample.java (1 hunks)
  • testng-core/src/test/java/test/reports/XmlReporterTest.java (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • testng-core/src/test/java/test/reports/SimpleIgnoredSample.java
🔇 Additional comments (1)
CHANGES.txt (1)

8-8: LGTM! The changelog entry accurately reflects the PR objectives.

The addition "Fixed: GITHUB-3189: Incorrect number of ignored tests displayed in the XML results" properly documents the fix for issue #3189 which addresses the incorrect display of ignored tests count in XML results.

Comment on lines +111 to +112
assertThat(ignored).isEqualTo(1);
assertThat(total).isEqualTo(3);
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

The assertions don't match the actual test implementation

The assertions expect a total of 3 tests with 1 ignored test, but SimpleIgnoredSample.java only contains a single test method that is ignored. This means the assertions assertThat(ignored).isEqualTo(1); assertThat(total).isEqualTo(3); are incorrect as they don't reflect the actual test class implementation.

  • SimpleIgnoredSample.java has only one test method ignored() which is annotated with both @Test and @Ignore
  • The total count should be 1 (not 3)
  • The ignored count is correctly set to 1
🔗 Analysis chain

Verify the SimpleIgnoredSample test class implementation.

The assertions expect exactly one ignored test and a total of 3 tests. Let's verify that SimpleIgnoredSample.class is properly implemented with one @Ignore annotated test method.


Let me gather more information about the SimpleIgnoredSample class implementation.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify SimpleIgnoredSample class implementation

# Find and check the content of SimpleIgnoredSample class
echo "Searching for SimpleIgnoredSample class definition..."
rg -l "class SimpleIgnoredSample"

echo "Checking for @Ignore annotation usage..."
ast-grep --pattern 'class SimpleIgnoredSample {
  $$$
  @Ignore
  $$$
}'

Length of output: 382


Script:

#!/bin/bash
# Get the content of SimpleIgnoredSample class to verify test methods
echo "Content of SimpleIgnoredSample class:"
cat testng-core/src/test/java/test/reports/SimpleIgnoredSample.java

# Count total test methods
echo -e "\nCounting test methods..."
ast-grep --pattern 'class SimpleIgnoredSample {
  $$$
  @Test
  $$$
}'

# Count ignored test methods
echo -e "\nCounting ignored test methods..."
ast-grep --pattern 'class SimpleIgnoredSample {
  $$$
  @Ignore
  @Test
  $$$
}'

Length of output: 637

@@ -228,7 +228,7 @@ public void add(Count count) {
this.failed += count.failed;
this.skipped += count.skipped;
this.retried += count.retried;
this.ignored += count.retried;
this.ignored += count.ignored;
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Add test coverage for ignored tests counting in XML reports

Based on the verification results:

  1. The JUnitReportsTest validates ignored count in JUnit reports but not for the XML reporter
  2. No specific test exists for the Count class's ignored tests accumulation
  3. The fix needs test coverage to prevent regression

Consider adding test coverage:

  • Add test case in CountTest.java to verify Count class's ignored tests accumulation
  • Add test case in AbstractXmlReporterTest to verify ignored tests are correctly reported in XML
🔗 Analysis chain

LGTM! This fix correctly addresses the ignored tests counting issue.

The change fixes issue #3189 by correctly accumulating the ignored count instead of erroneously using the retried count. This ensures that the XML report accurately reflects the number of ignored tests.

Consider adding a clarifying comment to document this fix:

  public void add(Count count) {
    this.passed += count.passed;
    this.failed += count.failed;
    this.skipped += count.skipped;
    this.retried += count.retried;
+   // Fixed in PR #3190: Use ignored count instead of retried count to fix incorrect reporting
    this.ignored += count.ignored;
  }

Let's verify that test coverage exists for this fix:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for test coverage of the ignored tests counting functionality

# Look for test files that verify ignored test counting
rg -l "ignored.*count|count.*ignored" --type java test/

Length of output: 103


Script:

#!/bin/bash
# Let's first find the test directory structure
fd -t d "test"

# Then search for test files related to XML reporting or Count class
rg -l "ignored.*count|count.*ignored" --type java

Length of output: 2838


Script:

#!/bin/bash
# Let's examine the JUnitReportsTest.java to see if it tests ignored count
rg -A 10 -B 10 "ignored.*count|count.*ignored" testng-core/src/test/java/test/junitreports/JUnitReportsTest.java

# Let's also check for any test files that might test the Count class directly
rg -l "class.*Count.*Test|test.*Count" --type java testng-core/src/test/

Length of output: 5981


Script:

#!/bin/bash
# Let's examine CountTest.java which might be directly testing the Count class
rg -A 10 -B 10 "class CountTest" testng-core/src/test/java/test/CountTest.java

# Also check if there are any existing tests for ignored tests in XML reports
ast-grep --pattern 'class $_ {
  $$$
  @Test
  $$$
  void $_($$) {
    $$$
    ignored$$$
    $$$
  }
  $$$
}'

Length of output: 870

@krmahadevan krmahadevan merged commit 3b79840 into testng-team:master Nov 22, 2024
7 of 10 checks passed
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.

Incorrect number of ignored tests displayed in the XML results
4 participants