executiontest-runner

Test Runner file - Hover over error does not prompt user to import api


I created a New Maven project in Eclipse and then created a new "Feature file", "Step Definition" & "Testrunner". However I see quite a few error messages when I hover over the different annotations on the Test Runner class. See below {1 to 5}

I did a lot of research over the internet and added a few dependencies in the pom.xml file but nothing seem to work.

I currently have the following dependencies in my pom.xml file

<dependency>

  <groupId>junit</groupId>

  <artifactId>junit</artifactId>

  <version>3.8.1</version>

  <scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<groupId>io.cucumber</groupId>

<artifactId>cucumber-java</artifactId>

<version>6.8.2</version>
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<groupId>io.cucumber</groupId>

<artifactId>cucumber-junit</artifactId>

<version>6.8.2</version>

<scope>test</scope>
  1. When I hover my mouse over Cucumber I get the following message
  1. When I hover my mouse over @RunWith I get the following
  1. When I hover my mouse over @CucumberOptions I get the following
  1. When I hover my mouse over import cucumber.api.junit.Cucumber; I get the following
  1. When I hover my mouse over import cucumber.api.CucumberOptions; I get the following

Seems like its got to do something with the jre file. Here are the solutions i have tried based on responses I could find in stackoverflow A] Some solutions over the internet suggested that I add the following dependency to the pom.xml file, but it did not resolve the issue

<groupId>info.cukes</groupId>

<artifactId>cucumber-junit</artifactId>

<version>1.2.6</version>

<type>pom</type>

<scope>test</scope>

NOTE:- Even after adding these to the pom.xml file i do not see it under Maven Dependencies list.

B] added import cucumber.junit.Cucumber;

but even this did not help

C] Commented out @RunWith(Cucumber, class) and added the following dependency to the pom.xml file

<groupId>info.cukes</groupId>

<artifactId>cucumber-junit</artifactId>

<version>1.2.5</version>

<type>pom</type>

<scope>test</scope>

NOTE:- The error message against "import cucumber.api.CucumberOptions;" disappeared but error message against "import cucumber.api.junit.Cucumber;" still shows.

Regards, Rohit


Solution

  • I was able to resolve this issue.

    Solution:- Verified if the Eclipse Environment was using JUNIT4

    Steps:

    1. Clicked on Project--> Properties--> Java Build Path --> Library

    2. Then clicked on Add Library

    3. On the "Select the Library type to add" window selected JUNIT & clicked on Next & then Finish

      JUNIT showed up on the Java Build Path window

    4. Clicked on Apply and Close.