Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未定义的步骤参考-Intellij Java_Java_Selenium Webdriver_Intellij Idea_Cucumber - Fatal编程技术网

未定义的步骤参考-Intellij Java

未定义的步骤参考-Intellij Java,java,selenium-webdriver,intellij-idea,cucumber,Java,Selenium Webdriver,Intellij Idea,Cucumber,我正在用Cucumber和Java创建一个测试自动化框架。我能够创建步骤定义并启动测试。然而,在Intellij中我的小黄瓜功能中,它总是向我显示步骤没有重新注册。因此,我无法导航到实现的步骤定义 我真的尝试了我遇到的每一个解决方案 //xml-我的所有依赖项都在这个文件中,它们是支持我的解决方案所必需的。我使用了Maven存储库中所有依赖项的最新版本 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://m

我正在用Cucumber和Java创建一个测试自动化框架。我能够创建步骤定义并启动测试。然而,在Intellij中我的小黄瓜功能中,它总是向我显示步骤没有重新注册。因此,我无法导航到实现的步骤定义

我真的尝试了我遇到的每一个解决方案

//xml-我的所有依赖项都在这个文件中,它们是支持我的解决方案所必需的。我使用了Maven存储库中所有依赖项的最新版本

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>execute_auto</groupId>
    <artifactId>execute_auto</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>4.7.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.5.3</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/gherkin -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>gherkin</artifactId>
            <version>5.0.0</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-jvm-deps -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.6</version>
            <scope>provided</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>

        <!-- Web driver manager dependency -->

        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.6.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>3.6.2</version>
            <scope>compile</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
//Myfeature—这是我用来自动化测试用例的示例特性

Feature: LoginFeature
Scenario: Log in
Given The user login to the application
When the credentials are entered
Then the homepage is viewed

这是因为Intellij希望您在自动获取步骤定义之前进行一些配置。链接将显示您需要的逐步设置过程(如果您尚未看到)。当我在Intellij中运行我的第一个cucumber特性文件时,我遇到了同样的问题。同样,在它工作之后,您可以进行我在本文中展示的更多调整。

这在最新的IntelliJ更新中得到了修复:


.

实际上,我已经尝试了您在第一个链接中提到的步骤。它仍然告诉我,这些步骤是无法识别的。当我从功能文件创建所有新的步骤定义时,它会生成如下步骤:@cumber.api.java.en。然后(“我可以在步骤定义文件中看到生成的步骤”)public void我可以在步骤定义文件()中查看生成的步骤{我认为这是因为Cucumber包的导入依赖性已经从Cucumber.api.java.en.Then演变为io.Cucumber.java.en.Then(如果我是正确的)。@mpkorstanje我尝试了包含链接中所述的插件,但仍然无法工作!这是因为IDEA还不支持这一点。从@mpkorstanje的评论来看,Intellij似乎对黄瓜的新进口位置有问题,就像你所怀疑的那样。不过,为了确定,您是否尝试过使用旧的import语句,看看它是否工作正常?我最近在Intellij中使用Cucumber for Java及其注释,没有问题。建议将代码作为文本而不是图像发布。欢迎使用堆栈溢出!请参阅:SO的期望是,用户提问时不仅要进行研究以回答自己的问题,还要分享研究、代码尝试和结果。这表明你花了时间来帮助自己,它使我们避免重复显而易见的答案,最重要的是,它帮助你得到一个更具体和相关的答案!另见:@JeffC,你说得对。我已经很久没用了。因此,我不太了解规则。希望随着时间的推移,情况会好转。就研究而言,我浏览了谷歌上几乎所有的链接,这些链接是在我输入“intellij功能文件中未定义的步骤参考java”后显示的。如果将ex@Given(“用户登录到应用程序”)修改为@Given(“用户登录到应用程序$”),会发生什么?该步骤可识别吗?@MrCas该步骤在.feature文件中仍然无法识别!谢谢我刚刚更新了我的intellij,它工作得非常好!
Feature: LoginFeature
Scenario: Log in
Given The user login to the application
When the credentials are entered
Then the homepage is viewed