-
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 for #3189 - fixed ignored testcases count #3190
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package test.reports; | ||
|
||
import org.testng.annotations.Ignore; | ||
import org.testng.annotations.Test; | ||
|
||
public class SimpleIgnoredSample { | ||
|
||
@Test | ||
@Ignore | ||
public void ignored() {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,7 +93,12 @@ public void ensureReportGenerationWhenTestMethodIsWrappedWithWrappedTestNGMethod | |
@Test(description = "GITHUB-2886") | ||
public void ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports() throws Exception { | ||
File file = | ||
runTest(RuntimeBehavior.FILE_NAME, null, JekyllTestSample.class, HydeTestSample.class); | ||
runTest( | ||
RuntimeBehavior.FILE_NAME, | ||
null, | ||
JekyllTestSample.class, | ||
HydeTestSample.class, | ||
SimpleIgnoredSample.class); | ||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); | ||
DocumentBuilder builder = factory.newDocumentBuilder(); | ||
Document doc = builder.parse(file); | ||
|
@@ -103,8 +108,8 @@ public void ensureConfigurationMethodsAreNotCountedAsSkippedInXmlReports() throw | |
int total = Integer.parseInt(node.getAttributes().getNamedItem("total").getNodeValue()); | ||
int passed = Integer.parseInt(node.getAttributes().getNamedItem("passed").getNodeValue()); | ||
int failed = Integer.parseInt(node.getAttributes().getNamedItem("failed").getNodeValue()); | ||
assertThat(ignored).isZero(); | ||
assertThat(total).isEqualTo(2); | ||
assertThat(ignored).isEqualTo(1); | ||
assertThat(total).isEqualTo(3); | ||
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
🔗 Analysis chainVerify the SimpleIgnoredSample test class implementation. The assertions expect exactly one ignored test and a total of 3 tests. Let's verify that Let me gather more information about the SimpleIgnoredSample class implementation. 🏁 Scripts executedThe 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 |
||
assertThat(passed).isEqualTo(2); | ||
assertThat(failed).isZero(); | ||
} | ||
|
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.
💡 Codebase verification
Add test coverage for ignored tests counting in XML reports
Based on the verification results:
Consider adding test coverage:
🔗 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:
Length of output: 103
Script:
Length of output: 2838
Script:
Length of output: 5981
Script:
Length of output: 870