Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JUnitTestClass sets XmlTest as null when running JUnit 4 Tests using TestNG #2792

Closed
7 tasks
kamal-kaur04 opened this issue Aug 15, 2022 · 0 comments · Fixed by #2848
Closed
7 tasks

JUnitTestClass sets XmlTest as null when running JUnit 4 Tests using TestNG #2792

kamal-kaur04 opened this issue Aug 15, 2022 · 0 comments · Fixed by #2848
Milestone

Comments

@kamal-kaur04
Copy link

TestNG Version

Note: only the latest version is supported

Expected behavior

The expectation is to get test using getXmlTest() method in Listeners such as IInvokedMethodListener and ITestListener while running JUnit 4 tests using testNG.

Actual behavior

While looking at JUnitTestClass, it seems like the xmlTest has been returned as null. Is there a way to get xmlTest in the ITestContext and ITestResult?

public class InvokedMethodListener implements IInvokedMethodListener {
    @Override
    public void beforeInvocation(IInvokedMethod method, ITestResult testResult) {
        Thread.currentThread().setName(method.getTestMethod().getMethodName() + "@" + testResult.getTestClass().getXmlTest().getAllParameters());     // null
    }
public class TmpSuiteListener implements ITestListener {
    @Override
    public void onTestStart(ITestResult result) {
        try {
            System.out.println(result.getTestClass().getXmlTest())    // null
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Is the issue reproducible on runner?

  • Shell
  • Maven
  • Gradle
  • Ant
  • Eclipse
  • IntelliJ
  • NetBeans

Test case sample

Please, share the test case (as small as possible) which shows the issue

Contribution guidelines

Incase you plan to raise a pull request to fix this issue, please make sure you refer our Contributing section for detailed set of steps.

@kamal-kaur04 kamal-kaur04 changed the title JUnitTestClass sets XmlTest as null JUnitTestClass sets XmlTest as null when running JUnit Tests using TestNG Aug 15, 2022
@kamal-kaur04 kamal-kaur04 changed the title JUnitTestClass sets XmlTest as null when running JUnit Tests using TestNG JUnitTestClass sets XmlTest as null when running JUnit 4 Tests using TestNG Aug 15, 2022
krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 3, 2022
krmahadevan added a commit to krmahadevan/testng that referenced this issue Dec 3, 2022
@krmahadevan krmahadevan added this to the 7.6.2 milestone Dec 3, 2022
krmahadevan added a commit that referenced this issue Dec 4, 2022
@krmahadevan krmahadevan modified the milestones: 7.6.2, 7.7.0 Dec 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants