gpt4 book ai didi

maven - 运行测试运行程序时输出为 0 Scenarios

转载 作者:行者123 更新时间:2023-12-04 01:27:06 25 4
gpt4 key购买 nike

我正在尝试运行一些测试作为学习 cucumber 的一部分。但我得到的结果是 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>

输出:
0 场景
0 步
0m0.000s

进程完成退出代码 0features = "src/test/java/features",

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

最佳答案

Scenario之间的空间和 :是问题

替换这个

Scenario : Home page default login


Scenario: Home page default login

关于maven - 运行测试运行程序时输出为 0 Scenarios,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61728664/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com