allure-framework / allure2

Allure Report is a flexible, lightweight multi-language test reporting tool. It provides clear graphical reports and allows everyone involved in the development process to extract the maximum of information from the everyday testing process
https://allurereport.org/
Apache License 2.0
4.14k stars 703 forks source link

When integration with TestNG, how to show the parameters name in report, not arg0, arg1... #886

Closed chuanding closed 5 years ago

chuanding commented 5 years ago

[//]: # ( . Note: for support questions, please use Stackoverflow or Gitter. . This repository's issues are reserved for feature requests and bug reports. . . In case of any problems with Allure Jenkins plugin please use the following repository . to create an issue: https://github.com/jenkinsci/allure-plugin/issues . . Make sure you have a clear name for your issue. The name should start with a capital . letter and no dot is required in the end of the sentence. An example of good issue names: . . - The report is broken in IE11 . - Add an ability to disable default plugins . - Support emoji in test descriptions )

I'm submitting a ...

What is the current behavior?

I use testNG and allure, and I pass the parameters via @dataproveide supported by TestNG, and then generated the allure report. But I found that the parameters in the report show the name as arg0, arg1, this is unreadable for the human.

image

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

What is the expected behavior?

Is there any way to show the real parameters name that I defined in the test function or an Object field names?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

Allure version 2.2.0
Test framework testng@6.8
Allure adaptor allure-testng@2.0-BETA11
Generate report using allure-maven@2.18

Other information

[//]: # ( . e.g. detailed explanation, stacktraces, related issues, suggestions . how to fix, links for us to have more context, eg. Stackoverflow, Gitter etc )

baev commented 5 years ago
chuanding commented 5 years ago

Thanks baev! love you!

salk7 commented 5 years ago

@baev is there a way to show param names in same order as given in the test method?

as of now it is sorted based on parameter name.

igor-rubis commented 2 years ago

Is there a way to set -parameters in the build.gradle file. I found the following way but it didn't work:

compileJava {
    options.compilerArgs << '-parameters' 
}
TimeInvestor commented 2 years ago

@baev is there a way to show param names in same order as given in the test method?

as of now it is sorted based on parameter name.

I have the same question here. Anyone got the answer?

kosticbv commented 1 month ago

@baev same question as these 2 bellow:

@baev is there a way to show param names in same order as given in the test method? as of now it is sorted based on parameter name.

I have the same question here. Anyone got the answer?

@baev is there a way to show param names in same order as given in the test method?

as of now it is sorted based on parameter name.

Test parameters seem to be sorted alphabetically, even if the LinkedHashMap is used to store params

This is my implementation:

public static void attachParametersToTest(Map<String, String> rowData) {
        Allure.getLifecycle().updateTestCase(test ->
                test.setParameters(test.getParameters()
                        .stream()
                        .filter(parameter -> parameter.getName().isEmpty())
                        .collect(Collectors.toList()))); //deletes the parameters set so far (the method is invoked at the end of execution)
        rowData.forEach((key,value) -> {
            Allure.getLifecycle().updateTestCase(test -> test.getParameters().add(new Parameter()
                    .setName(key)
                    .setValue(value)));
        }); //adds the parameters from LinkedHashMap so the order should be preserved
    }
even after this, the test parameters are sorted alphabetically based on the param name