Fix for #893 - param annotation name not coming up in report · allure-framework/allure-java@e19178f

1+

/*

2+

* Copyright 2016-2024 Qameta Software Inc

3+

*

4+

* Licensed under the Apache License, Version 2.0 (the "License");

5+

* you may not use this file except in compliance with the License.

6+

* You may obtain a copy of the License at

7+

*

8+

* http://www.apache.org/licenses/LICENSE-2.0

9+

*

10+

* Unless required by applicable law or agreed to in writing, software

11+

* distributed under the License is distributed on an "AS IS" BASIS,

12+

* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

13+

* See the License for the specific language governing permissions and

14+

* limitations under the License.

15+

*/

16+

package io.qameta.allure.testng.samples;

17+18+

import io.qameta.allure.Param;

19+

import org.testng.annotations.DataProvider;

20+

import org.testng.annotations.Test;

21+22+

import static io.qameta.allure.Allure.step;

23+24+

/**

25+

* @author Sambhav Dave sambhavd4@gmail.com

26+

*/

27+

public class CustomParameterNamesTest {

28+29+

@DataProvider

30+

public static Object[][] testDataForParamNames() {

31+

return new Object[][]{

32+

{1, 1, 2, 5}

33+

};

34+

}

35+36+

@Test(dataProvider = "testDataForParamNames")

37+

public void sumTest(

38+

@Param(name = "First") Integer a,

39+

@Param(name = "Second") Integer b,

40+

@Param(name = "Third") Integer expectedSum,

41+

@Param(name = "Fourth") Integer unusedParam) {

42+43+

step("Arrange", () -> step(String.format("Use parameters: First = [%s], Second = [%s], Third = [%s], Fourth = [%s]",

44+

a, b, expectedSum, unusedParam)));

45+46+

Integer result = step("Act", () -> {

47+

step(String.format("Add First [%s] and Second [%s]", a, b));

48+

return a + b;

49+

});

50+51+

step("Assert", () -> {

52+

step(String.format("Compare result [%s] with expected [%s]", result, expectedSum));

53+

assert result.equals(expectedSum) : "Sum does not match the expected value";

54+

});

55+

}

56+57+

}