Maven 运行测试运行程序时,将输出设置为0

Maven 运行测试运行程序时,将输出设置为0,maven,cucumber,cucumber-java,Maven,Cucumber,Cucumber Java,作为学习黄瓜的一部分,我正在尝试进行一些测试。但我得到的结果是0个场景。在这里,我添加了我编写的代码: 登录。功能带有- Feature: Application Login S Scenario : Home page default login Given User is on Net banking landing page When user login into the application with username and password The

作为学习黄瓜的一部分,我正在尝试进行一些测试。但我得到的结果是0个场景。在这里,我添加了我编写的代码:

登录。功能带有-

Feature: Application Login   S
Scenario : Home page default login

    Given User is on Net banking landing page
    When user login into the application with  username and password
    Then Home page is populated
    And Cards are displayed
步骤定义

package stepDefinitions;

import cucumber.api.PendingException;

import cucumber.api.java.en.Given;

import cucumber.api.java.en.When;

import cucumber.api.java.en.Then;

import cucumber.api.java.en.And;

import cucumber.api.junit.Cucumber;

import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
public class StepDefinition {

    @Given("^User is on Net banking landing page$")
    public void user_is_on_net_banking_landing_page() throws Throwable {
        System.out.println("User on landing page");
    }

    @When("^user login into the application with  username and password$")
    public void user_login_into_the_application_with_username_and_password() throws Throwable {
        System.out.println("Login successfully");
    }

    @Then("^Home page is populated$")
    public void home_page_is_populated() throws Throwable {
        System.out.println("User on Home page");
    }

    @And("^Cards are displayed$")
    public void cards_are_displayed() throws Throwable {
        System.out.println("Displaying cards");
    }

}
测试跑步者-

package com.edstem.CucumberOptions;

import cucumber.api.CucumberOptions;

import cucumber.api.junit.Cucumber;

import org.junit.runner.RunWith;

@RunWith(Cucumber.class)

@CucumberOptions(
            features = "src/test/java/features",
            glue = {"stepDefinitions"})

public class TestRunner {
}
pom.xml-

<?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>org.example</groupId>
    <artifactId>cucumber-learning</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.0.11</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable</artifactId>
            <version>1.1.12</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-testng</artifactId>
            <version>4.2.3</version>
        </dependency>


    </dependencies>

</project>

4.0.0
org.example
黄瓜学习
1.0-快照
UTF-8
信息杯
黄瓜-java8
释放
测试
信息杯
黄瓜刺柏
释放
测试
信息杯
黄瓜皮容器
释放
测试
朱尼特
朱尼特
4.11
测试
信息杯
黄瓜
1.0.11
聚甲醛
黄瓜
数据表
1.1.12
黄瓜
黄瓜试验
4.2.3
输出: 0场景 0步 0m0.000s

进程已完成,退出代码为0features=“src/test/java/features”


您能给我一个解决方案吗,因为我找不到修复它的方法。

假设您的功能文件正确地放置在
src/test/java/features
中,问题是您的胶水没有正确地设置到步骤定义,或者类路径缺少配置文件路径

检查两者,如果仍然不起作用,请发布您的运行配置和项目结构。

1)您不需要用@RunWith注释步骤定义类。只要跑步者就够了

2) 特性应该放在src/test/resources/Features中,而不是放在src/test/java中

3) 您使用的是非常旧的cucumber版本。尝试切换到最新版本

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.7.0</version>

黄瓜
黄瓜爪哇
5.7.0

问题在于
场景
之间的空间

替换这个

Scenario : Home page default login


您是如何执行测试的?从命令行还是通过IDE?
Scenario: Home page default login