首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >测试运行程序文件- Hover错误不会提示用户导入api

测试运行程序文件- Hover错误不会提示用户导入api
EN

Stack Overflow用户
提问于 2020-11-09 19:25:22
回答 1查看 123关注 0票数 0

我在Eclipse中创建了一个New项目,然后创建了一个新的"Feature“,”“& "Testrunner”。但是,当我悬停在Test类的不同注释上时,我看到了相当多的错误消息。见下文{1至5}

我在互联网上做了很多研究,并在pom.xml文件中添加了一些依赖项,但似乎没有什么效果。

当前,我的pom.xml文件中有以下依赖项

代码语言:javascript
复制
<dependency>

  <groupId>junit</groupId>

  <artifactId>junit</artifactId>

  <version>3.8.1</version>

  <scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
代码语言:javascript
复制
<groupId>io.cucumber</groupId>

<artifactId>cucumber-java</artifactId>

<version>6.8.2</version>
代码语言:javascript
复制
<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
代码语言:javascript
复制
<groupId>io.cucumber</groupId>

<artifactId>cucumber-junit</artifactId>

<version>6.8.2</version>

<scope>test</scope>

当我将鼠标悬停在黄瓜上时,我得到以下message

  • Cucumber不能解析为variable
  1. When,鼠标悬停在@RunWith上,得到的following
  • RunWith不能解析为type
  1. When,鼠标悬停在@CucumberOptions上,得到的following
  • CucumberOptions不能解析为type
  1. When,鼠标悬停在导入cucumber.api.junit.Cucumber上;我得到的following
  • The导入cucumber.api.junit不能是resolved
  1. When,我将鼠标悬停在导入cucumber.api.CucumberOptions上;我得到了following
  • The导入cucumber.api.CucumberOptions无法被解析的

好像要用jre文件做点什么。以下是我尝试过的基于堆栈溢出A中的响应的解决方案:因特网上的一些解决方案建议我在pom.xml文件中添加下面的依赖项,但它没有解决这个问题

代码语言:javascript
复制
<groupId>info.cukes</groupId>

<artifactId>cucumber-junit</artifactId>

<version>1.2.6</version>

<type>pom</type>

<scope>test</scope>

注意:-即使将这些添加到pom.xml文件中,我也不会在Maven依赖项列表中看到它。

(B)增加进口cucumber.junit.Cucumber;

但即使这样也没有帮助

C]注释掉@RunWith(Cucumber,class)并将以下依赖项添加到pom.xml文件中

代码语言:javascript
复制
<groupId>info.cukes</groupId>

<artifactId>cucumber-junit</artifactId>

<version>1.2.5</version>

<type>pom</type>

<scope>test</scope>

注意:-针对“导入cucumber.api.CucumberOptions”的错误消息消失了,但针对“导入cucumber.api.junit.Cucumber”的错误消息仍然显示。

你好,罗希特

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-10 04:03:58

我解决了这个问题。

解决方案:-验证Environment是否使用JUNIT4

步骤:

  1. 单击项目->属性-> Java > Library

然后

  1. 单击Add Library

  1. 在“选择库类型以添加”窗口中选择了JUNIT &单击Next &然后完成

JUNIT出现在Java窗口上。

  1. 单击Apply并关闭.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64758032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档