diff --git a/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java b/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java index db318072b..ebbc0a63e 100644 --- a/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java +++ b/allure-testng/src/main/java/io/qameta/allure/testng/AllureTestNg.java @@ -21,7 +21,6 @@ import io.qameta.allure.Muted; import io.qameta.allure.Severity; import io.qameta.allure.SeverityLevel; -import io.qameta.allure.Param; import io.qameta.allure.model.FixtureResult; import io.qameta.allure.model.Label; import io.qameta.allure.model.Link; @@ -75,7 +74,6 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; import java.util.stream.Collectors; -import java.util.stream.IntStream; import java.util.stream.Stream; import static io.qameta.allure.util.ResultsUtils.ALLURE_ID_LABEL_NAME; @@ -781,23 +779,9 @@ private List getParameters(final ITestContext context, .map(Parameters::value) .orElse(new String[]{}); - final List reflectionNames = IntStream - .range(0, parameters.length) - .mapToObj(index -> { - final Parameter parameter = createParameter(m.getParameters()[index].getName(), parameters[index]); - Stream.of(m.getParameters()[index].getAnnotationsByType(Param.class)) - .findFirst() - .ifPresent(param -> { - Stream.of(param.name().trim()) - .map(String::trim) - .filter(name -> !name.isEmpty()) - .findFirst() - .ifPresent(parameter::setName); - parameter.setMode(param.mode()); - parameter.setExcluded(param.excluded()); - }); - return parameter; - }).collect(Collectors.toList()); + final String[] reflectionNames = Stream.of(m.getParameters()) + .map(java.lang.reflect.Parameter::getName) + .toArray(String[]::new); int skippedCount = 0; for (int i = 0; i < parameterTypes.length; i++) { @@ -813,8 +797,8 @@ private List getParameters(final ITestContext context, continue; } - if (i < reflectionNames.size()) { - result.put(reflectionNames.get(i).getName(), ObjectUtils.toString(parameters[i])); + if (i < reflectionNames.length) { + result.put(reflectionNames[i], ObjectUtils.toString(parameters[i])); } } diff --git a/allure-testng/src/test/java/io/qameta/allure/testng/samples/ParameterizedTest.java b/allure-testng/src/test/java/io/qameta/allure/testng/samples/ParameterizedTest.java index 2f7751130..385689b14 100644 --- a/allure-testng/src/test/java/io/qameta/allure/testng/samples/ParameterizedTest.java +++ b/allure-testng/src/test/java/io/qameta/allure/testng/samples/ParameterizedTest.java @@ -15,13 +15,11 @@ */ package io.qameta.allure.testng.samples; -import io.qameta.allure.Param; +import io.qameta.allure.Step; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static io.qameta.allure.Allure.step; - /** * @author Egor Borisov ehborisov@gmail.com */ @@ -40,36 +38,13 @@ public Object[][] testData() { }; } - @DataProvider - public static Object[][] testDataForParamNames() { - return new Object[][]{ - {1, 1, 2, 5}, - {2, 2, 4, 5} - }; - } - @Test(dataProvider = "testData") public void parameterizedTest(String param) { step(param); } - @Test(dataProvider = "testDataForParamNames") - public void sumTest( - @Param(name = "First") Integer a, - @Param(name = "Second") Integer b, - @Param(name = "Third") Integer r, - @Param(name = "Fourth") Integer s) { - - step(("Arrange"), () -> { - step(String.format("Take collection №[%s] of parameters", a)); - }); - step(("Act"), () -> { - step(String.format("Add [%s]", a) + String.format("to [%s]", b)); - }); - step(("Assert"), () -> { - step("Compare the sum"); - assert a + b == r; - }); + @Step + public void step(String param) { } } diff --git a/allure-testng/src/test/resources/suites/parameterized-test.xml b/allure-testng/src/test/resources/suites/parameterized-test.xml index ce3abb24d..6911eb613 100644 --- a/allure-testng/src/test/resources/suites/parameterized-test.xml +++ b/allure-testng/src/test/resources/suites/parameterized-test.xml @@ -2,12 +2,10 @@ - - - - + +