trivago/cucable-plugin

Running Cucumber feature file doesn’t generate step definitions

Naumansh opened this issue · 4 comments

Describe the bug
When a new step is implemented in a feature file. The step definitions is not generate for that step and it shows the execution is skipped.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new step in feature file
  2. Run the scenario taf
  3. [WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 8.896

Expected behavior
The step definition skelton is shown on the terminal.

CustomCreator.java

@RunWith(Cucumber.class)
@CucumberOptions(
        glue = {"setup"},
        features = {"target/parallel/features/[CUCABLE:FEATURE].feature"},
        plugin = {"json:target/cucumber-report/[CUCABLE:RUNNER].json","pretty"},
        tags = {"not @wip"},
        monochrome = true
)
public class CustomCreator {

}

Pom.xml

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skipTests>true</skipTests>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<version>${maven.failsafe.plugin.version}</version>
				<executions>
					<execution>
						<id>Run parallel tests</id>
						<phase>integration-test</phase>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<forkCount>${threads}</forkCount>
					<testFailureIgnore>true</testFailureIgnore>
					<disableXmlReport>true</disableXmlReport>
					<argLine>-Dfile.encoding=UTF-8</argLine>
					<excludes>
						<exclude>**/IT*.java</exclude>
					</excludes>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>${maven.compiler.plugin.version}</version>
				<configuration>
					<source>11</source>
					<target>11</target>
				</configuration>
			</plugin>
			<plugin>
				<groupId>com.trivago.rta</groupId>
				<artifactId>cucable-plugin</artifactId>
				<version>${cucable.version}</version>
				<executions>
					<execution>
						<id>generate-test-resources</id>
						<phase>generate-test-resources</phase>
						<goals>
							<goal>parallel</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
		
					<sourceFeatures>src/test/resources/features</sourceFeatures>
					<generatedFeatureDirectory>${generated.feature.directory}</generatedFeatureDirectory>
					<generatedRunnerDirectory>${generated.runner.directory}</generatedRunnerDirectory>
					<parallelizationMode>scenarios</parallelizationMode>
					<includeScenarioTags>${tags}</includeScenarioTags>
					<logLevel>minimal</logLevel>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>${maven.build.helper.plugin.version}</version>
				<executions>
					<execution>
						<id>add-test-source</id>
						<phase>generate-test-sources</phase>
						<goals>
							<goal>add-test-source</goal>
						</goals>
						<configuration>
							<sources>
								<source>${generated.runner.directory}</source>
							</sources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>com.trivago.rta</groupId>
				<artifactId>cluecumber-report-plugin</artifactId>
				<version>${report.version}</version>
				<executions>
					<execution>
						<id>report</id>
						<phase>post-integration-test</phase>
						<goals>
							<goal>reporting</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<sourceJsonReportDirectory>${cucumber.report.json.location}</sourceJsonReportDirectory>
					<generatedHtmlReportDirectory>${generated.report.location}</generatedHtmlReportDirectory>
				<failScenariosOnPendingOrUndefinedSteps>true</failScenariosOnPendingOrUndefinedSteps>
					<expandBeforeAfterHooks>true</expandBeforeAfterHooks>
					<logLevel>off</logLevel>
				</configuration>
			</plugin>
		</plugins>
	</build>

Hello @Naumansh , I am not sure what you mean. Cucable does not generate step definitions.
Can you explain this further? Because what you describe is expected behavior.

hi @laxersaz The standard cucumber execution usually generates a skeleton step definition for any new step.
However, it is not happening with me. I might need to update some part of my cucuable settings as it is skipping the execution in case of any new step .

Running hellocucumber.RunCucumberTest
Feature: Is it Friday yet?
Everybody wants to know when it's Friday

Scenario: Sunday isn't Friday # hellocucumber/is_it_friday_yet.feature:4
Given today is Sunday # null
When I ask whether it's Friday yet # null
Then I should be told "Nope" # null

Undefined scenarios:
hellocucumber/is_it_friday_yet.feature:4 # Sunday isn't Friday

1 Scenarios (1 undefined)
3 Steps (3 undefined)
0m0.040s

You can implement missing steps with the snippets below:

@given("today is Sunday")
public void today_is_Sunday() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}

@when("I ask whether it's Friday yet")
public void i_ask_whether_it_s_Friday_yet() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}

@then("I should be told {string}")
public void i_should_be_told(String string) {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
Copy each of the three snippets for the undefined steps and paste them into src/test/java/hellocucumber/Stepdefs.java .

See scenario reported as pending 🔗︎
Run Cucumber again. This time the output is a little different:


T E S T S

Running hellocucumber.RunCucumberTest
Feature: Is it Friday yet?
Everybody wants to know when it's Friday

Scenario: Sunday isn't Friday # hellocucumber/is_it_friday_yet.feature:4
Given today is Sunday # Stepdefs.today_is_Sunday()
io.cucumber.java.PendingException: TODO: implement me
at hellocucumber.Stepdefs.today_is_Sunday(Stepdefs.java:14)
at ?.today is Sunday(classpath:hellocucumber/is_it_friday_yet.feature:5)

When I ask whether it's Friday yet # Stepdefs.i_ask_whether_it_s_Friday_yet()
Then I should be told "Nope"       # Stepdefs.i_should_be_told(String)

Pending scenarios:
hellocucumber/is_it_friday_yet.feature:4 # Sunday isn't Friday

1 Scenarios (1 pending)
3 Steps (2 skipped, 1 pending)
0m0.188s

io.cucumber.java.PendingException: TODO: implement me
at hellocucumber.Stepdefs.today_is_Sunday(Stepdefs.java:13)
at ?.today is Sunday(classpath:hellocucumber/is_it_friday_yet.feature:5)

I think you are confusing Cucable and Cucumber. It sounds like your question is unrelated to Cucable.