硒在黄瓜试验中没有发现特征异常

问题描述 投票:0回答:1

我是黄瓜新手。当我试图单独运行功能文件时,我没有找到功能异常。我尝试了StackOverflow中已经提出的问题的所有建议,但这些建议并不适用于我。请帮我解决这个问题。

我的功能文件

Feature: CucumberJava

  Scenario: Logging in to Facebook using DataTables
    Given I have open the "Chrome" browser
    When I open Facebook website
    And Logging in to Facebook using DataTables
      | Feild               | Values              |
      | Email id            | [email protected]     |
      | Password            | dvfsgg              |
    Then Click on Login button

我的跑步者档案

package cucumberPackage;

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

@RunWith(Cucumber.class) 
//@Cucumber.Options(format = {"pretty", "html:target/cucumber"}) 
@Cucumber.Options(features="src/test/resources/demo/DataTables.feature",format = {"pretty", "html:target/cucumber"}) 
public class RunnerTest {

}

错误日志

cucumber.runtime.CucumberException: No features found at [src/test/resources/demo/DataTables.feature]
    at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:47)
    at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:82)
    at cucumber.junit.Cucumber.<init>(Cucumber.java:60)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createUnfilteredTest(JUnit4TestLoader.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:70)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:43)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
java selenium-webdriver cucumber cucumber-java cucumber-junit
1个回答
0
投票

做出以下假设

  • 你使用的是Cucumber版本<= 1.1.8(因为你使用的是@Cucumber.Options,已经在版本1.2.0中删除了,目前的Cucumber版本是3.0.2,也许可以考虑更新到最新版本
  • 当前目录中存在以下文件 src/test/java/cucumberPackage/RunnerTest.java src/test/resources/demo/DataTables.feature pom.xml

runner test.Java

在你的帖子中,有Cucumber.class的固定导入声明

// import cucumber.junit.Cucumber;
import cucumber.api.junit.Cucumber;

DataTables.feature

在你的帖子中

pom.hml

<?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>com.suboptimal</groupId>
    <artifactId>cuke-test.so</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <version.cucumber>1.1.8</version.cucumber>
    </properties>
    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>${version.cucumber}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${version.cucumber}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
    </dependencies>
</project>

使用mvn test运行测试会执行您的方案

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running cucumberPackage.RunnerTest
Feature: CucumberJava

  Scenario: Logging in to Facebook using DataTables # src/test/resources/demo/DataTables.feature:3
    Given I have open the "Chrome" browser
    When I open Facebook website
    And Logging in to Facebook using DataTables
    Then Click on Login button

1 Scenarios (1 undefined)
4 Steps (4 undefined)
0m0.000s


You can implement missing steps with the snippets below:
...
© www.soinside.com 2019 - 2024. All rights reserved.