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

Copy test result attributes when unexpected failures #3065

Merged
merged 1 commit into from Feb 12, 2024

Conversation

krmahadevan
Copy link
Member

@krmahadevan krmahadevan commented Feb 12, 2024

Closes #3064

Fixes #3064 .

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
    • Fixed TestResult loss and ConcurrentModificationException issues.
    • Addressed race conditions in creating Guice Modules.
    • Enhanced support for injecting custom listener factories.
  • New Features
    • Added functionality to copy attributes from the current test result to a newly created one before marking as FAILURE.
    • Introduced EvidenceListener and EvidenceRetryAnalyzer to improve test result attributes handling and retry logic.
  • Tests
    • Added new tests to verify that test result attributes are correctly carried forward.
    • Implemented a sample test case to demonstrate the setup of retry analyzers and listener configurations.

Copy link

coderabbitai bot commented Feb 12, 2024

Walkthrough

This update addresses critical issues within TestNG, focusing on enhancing the reliability of test result handling and listener functionality. It resolves problems related to the loss of TestResult data, exceptions during concurrent modifications, race conditions in Guice Module creation, and incorporates the ability to inject custom listener factories. By ensuring attributes of test results are preserved across retries and failures, this update significantly improves the consistency and integrity of test execution feedback.

Changes

Files Change Summary
testng-core/src/main/java/org/testng/internal/invokers/TestInvoker.java Added operation to copy attributes from the current to a new test result before marking as FAILURE.
testng-core/src/test/java/test/listeners/.../ListenersTest.java Introduced EvidenceListener and SampleTestCase imports and a new test to verify attribute preservation.
testng-core/src/test/java/test/listeners/issue3064/... (New Files) Added EvidenceListener.java, EvidenceRetryAnalyzer.java, SampleTestCase.java implementing listener interface, retry logic with intentional failure, and a test case class.

Assessment against linked issues

Objective Addressed Explanation
Ensure ITestResult instance consistency across ITestListener methods, retaining information. (#3064)
Address loss of ITestResult information due to IRetryAnalyzer creation failure. (#3064)
Modify exception handling for IRetryAnalyzer creation to prevent ITestResult information loss. (#3064)
Ensure attributes set in onTestStart() are available in subsequent listener methods like onTestFailure(). (#3064)

Poem

🐇💻 In the land of tests and code,
A rabbit hopped down the fix-it road.
"No more lost results," it cheered with glee,
"For TestNG's stronger, as it should be!"
🌟🛠 With every hop, a bug squashed flat,
In its wake, stable tests, just like that!
"To better days," it whispered, bright-eyed,
Where tests and results are never misapplied.

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>.
    • Generate unit-tests for this file.
  • 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 tests 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 generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

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.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 1774b2c and e77f1c2.
Files selected for processing (6)
  • CHANGES.txt (1 hunks)
  • testng-core/src/main/java/org/testng/internal/invokers/TestInvoker.java (1 hunks)
  • testng-core/src/test/java/test/listeners/ListenersTest.java (2 hunks)
  • testng-core/src/test/java/test/listeners/issue3064/EvidenceListener.java (1 hunks)
  • testng-core/src/test/java/test/listeners/issue3064/EvidenceRetryAnalyzer.java (1 hunks)
  • testng-core/src/test/java/test/listeners/issue3064/SampleTestCase.java (1 hunks)
Additional comments: 6
testng-core/src/test/java/test/listeners/issue3064/EvidenceRetryAnalyzer.java (1)
  • 8-10: LGTM. The intentional failure in the constructor serves the testing purpose.
testng-core/src/test/java/test/listeners/issue3064/EvidenceListener.java (1)
  • 6-18: LGTM. The implementation correctly sets an attribute on test start and captures the test result on failure for testing purposes.
testng-core/src/test/java/test/listeners/issue3064/SampleTestCase.java (1)
  • 16-27: LGTM. The suite setup correctly assigns the retry analyzer, and the test method is designed to fail for testing purposes.
testng-core/src/test/java/test/listeners/ListenersTest.java (1)
  • 42-47: LGTM. The test method correctly validates that attributes set in EvidenceListener are carried forward as expected.
testng-core/src/main/java/org/testng/internal/invokers/TestInvoker.java (1)
  • 975-976: Verify the implementation of attribute copying from the current test result to a newly created test result before marking the test as a failure, as described in the PR objectives. This specific change is not annotated in the provided code.
CHANGES.txt (1)
  • 3-3: Ensure the version number 7.10.0 is correctly incremented based on the previous version in the project history.

Comment on lines 1 to 6
Current
7.10.0
Fixed: GITHUB-3064: TestResult lost if failure creating RetryAnalyzer (Krishnan Mahadevan)
Fixed: GITHUB-3048: ConcurrentModificationException when injecting values (Krishnan Mahadevan)
Fixed: GITHUB-3050: Race condition when creating Guice Modules (Krishnan Mahadevan)
Fixed: GITHUB-3059: Support the ability to inject custom listener factory (Krishnan Mahadevan)
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process for the issues mentioned in the CHANGES.txt file for version 7.10.0 reveals the following:

  • GITHUB-3064 is still OPEN and assigned to milestone 7.10.0. This indicates that it might not be accurately resolved in this version as mentioned.
  • GITHUB-3048, GITHUB-3050, GITHUB-3059, and GITHUB-3045 are CLOSED and correctly assigned to milestone 7.10.0, aligning with the summary of changes.

Given this discrepancy with GITHUB-3064, it appears there is an issue with the completeness of the resolution as documented in the CHANGES.txt file for version 7.10.0.

Analysis chain

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [3-7]

The summary of changes for version 7.10.0 should be consistent with the project's versioning history and the detailed list of changes provided in the file. Confirm that all mentioned issues (e.g., GITHUB-3064, GITHUB-3048) are accurately resolved in this version.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify the resolution of mentioned GitHub issues
gh issue view 3064 --repo testng-team/testng
gh issue view 3048 --repo testng-team/testng
gh issue view 3050 --repo testng-team/testng
gh issue view 3059 --repo testng-team/testng
gh issue view 3045 --repo testng-team/testng
gh issue view 3038 --repo testng-team/testng
gh issue view 3022 --repo testng-team/testng

Length of output: 19211

Copy link
Member

@juherr juherr left a comment

Choose a reason for hiding this comment

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

Fix is ok. I've just no idea about the memory consumption.

@krmahadevan
Copy link
Member Author

Fix is ok. I've just no idea about the memory consumption.

There shouldn't be any memory implications because we are only copying the attributes that were set by a user's listener else where to be available in the test result being passed on to onTestFailure()

@krmahadevan krmahadevan merged commit d6ed528 into testng-team:master Feb 12, 2024
7 of 9 checks passed
@krmahadevan krmahadevan deleted the bugfix/3064 branch February 12, 2024 18:02
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.

TestResult lost if failure creating RetryAnalyzer
2 participants