cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

AsbtractTestNGCucumber Tests - Overriding Scenario Name in TestNG/JUnit Report #1929

Closed ash-skelton closed 4 years ago

ash-skelton commented 4 years ago

Describe the bug I have recently implemented TestNG to be able to run cucumber scenarios in parallel by extending AbstractTestNGCucumberTests in my JUnit runner. Runner file is initiated via maven command and I can see that TestNG is executing in parallel. The issue is that in the TestNG/JUnit .xml reports, the testcase name is now being overwritten with "runScenario" rather than the actual scenario name like it was before I implemented TestNG.

Runner

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
import org.junit.runner.RunWith;
import org.testng.annotations.DataProvider;

@RunWith(Cucumber.class)
@CucumberOptions(features = { "src/test/resources/Featurefiles" }, dryRun = false, strict = false, monochrome = true, plugin = {
        "pretty", "html:target/cucumber" }, glue = {"uk/os/stepdefinations"}, tags = {"@WMTS"})
public class RunTest extends AbstractTestNGCucumberTests {

    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();
    }
}

JUnit Report

<system-out/>
  <testcase name="runScenario" time="1.609" classname="uk.os.engagementservice.wmts.runner.RunTest"/>
  <system-out/>

How is it possible to use this AbstractTestNGCucumberTests class so that it still picks up the scenario name, rather than overriding it?

mpkorstanje commented 4 years ago
  1. You are mixing both JUnit and TestNG in the same class. JUnit and TestNG are different frameworks, you should only have to use one.

  2. I think you are talking about xml reports generated by Maven. These are not generated by neither JUnit nor TestNG. And you should probebly consult the TestNG and Maven documentation here.

  3. Cucumber can generate reports in the JUnit format by using a plugin "junit:target/cucumber.xml". You may be interested in using this.

  4. You are using a rather old version of Cucumber. Consider upgrading!