2

I have been playing around with Selenium Cucumber and came across this error message:

Type mismatch: Cannot convert from Class StepDefinition to Class?extends Runner

and here is my code:

package com.cucumber.JUnit;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

import com.cucumber.steps.StepDefinition;

@RunWith(StepDefinition.class)
@CucumberOptions(
  format = { "pretty", "html:report/test-report" },
  features = { "src/test/resources/sample.feature" },
  glue = { "com.cucumber.steps.StepDefinition" }
)

public class SampleCucumberJUnitRunner {
  //Note: As with all Cucumber tests, the .feature file(s) will define what 
will actually run.
}

Unable to understand the source of error even though I have imported the class correctly. Am I missing something???

Any help would be appreciable. Thanks in advance!!

1

Change @RunWith(StepDefinition.class) to @RunWith(Cucumber.class).

The Cucumber runner needs to run with a class that extends Runner.class; StepDefinition.class does not extends Runner.class.

  • Does this answer your question, or do you need something else? – Marit Feb 4 '18 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.