testng-team / testng

TestNG testing framework
https://testng.org
Apache License 2.0
1.99k stars 1.02k forks source link

Dataprovider parameters are not displayed in test result when using Factory annotation #2117

Closed AwareTo closed 5 years ago

AwareTo commented 5 years ago

TestNG Version 6.14.3

Expected behavior

TestNG results will show the parameters used. Without the parameters it is hard to distinguish which test case failed.

Actual behavior

Test Results do not display the the test parameters when using Factory annotation testng-results.xml Shows no parameters This issue is similar to another issue which is status is closed: https://github.com/cbeust/testng/issues/1041

Test case sample

public class Test3 {
    protected  List<String> data;

    @Factory (dataProvider = "getDataForInstances")
    public Test3(List<String> dataToSet) {
        this.data = dataToSet;
    }

  @Test
    public void Sanity(){
      String text = this.data.get(this.data.size()-1);
       System.out.println("Printing Parameters when running test method [" + text + "]");
       }

@DataProvider(name = "getDataForInstances")
public static Object[][] getDataForInstances( ITestNGMethod method) {
    System.out.println("Method name = " + method.getConstructorOrMethod().getName() + "()\n");

    return new Object[][] {
      {Collections.singletonList("Java")},
      {Arrays.asList("TestNG", "JUnit")},
      {Arrays.asList("Maven", "Gradle", "Ant")}
      };
    }

}

Thanks

krmahadevan commented 5 years ago

@AwareTo - This issue was fixed only in later versions. The latest released version of TestNG is 7.0.0-beta7. Please try using that and comment if this is still a problem.

AwareTo commented 5 years ago

@krmahadevan Indeed using latest beta test-ng-results.xml do present the parameters. However, I noticed that Eclipse do not show the parameters at the results window. Eclipse do show the dataprovider parameters if Factory annotation is not used. I noticed that the test-ng-results.xml has a different format when using Factory annotation. is this causing the Eclipse results issue? Thank you for your help!

krmahadevan commented 5 years ago

@AwareTo - For eclipse, you might want to log an issue in https://github.com/cbeust/testng-eclipse/issues

The TestNG eclipse plugin has a beta version that will be taking care of the new changes.

I noticed that the test-ng-results.xml has a different format when using Factory annotation.

Can you show the difference between the latest beta version and 6.14.3 ?

AwareTo commented 5 years ago

@krmahadevan I opened the following issue: https://github.com/cbeust/testng-eclipse/issues/437 So I guess this issue(2117) can be closed.

Can you show the difference between the latest beta version and 6.14.3 ?

I meant there is a difference at the xml tags of testng-results.xml xml when using Factory+Dataprovider annotations vs using the Dataprovider annotation only. Both using version 7.0.0-beta7 I guess this is by design and not an issue. Sorry if I was not clear. Thanks a lot for your help. It helped me to complete a framework I was working-on.

krmahadevan commented 5 years ago

Based on above comments, I am closing this issue.