java 如何一步一步运行@RunWith(Cucumber.class)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27060113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 11:08:04  来源:igfitidea点击:

How to run @RunWith(Cucumber.class) step by step

javajunitcucumberbddcucumber-jvm

提问by yeniden

I'm working on a BDD file and trying to test with JUnit.

我正在处理 BDD 文件并尝试使用 JUnit 进行测试。

I want to use RunCukesTest class with @RunWith(Cucumber.class).

我想将 RunCukesTest 类与 @RunWith(Cucumber.class) 一起使用。

I've searched on many websites about how to install requirements, but I couldn't find any website which explains it briefly, step by step.

我在许多网站上搜索了有关如何安装要求的信息,但找不到任何网站可以一步一步地对其进行简要说明。

Could you explain me briefly, step by step, how can I run my test?

你能简单地一步一步地解释我如何运行我的测试吗?

package test.newtest;

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

@RunWith(Cucumber.class)
public class RunCukesTest {
}

回答by Jim Barton

Cucumber will default to looking for feature files under the same package as RunCucksTest. You can also change the location(s) it will look for feature files by supplying the "features" option with the @CucumberOptionsannotation (in RunCucksTest). E. g.,

Cucumber 将默认在与 RunCucksTest 相同的包下查找功能文件。您还可以通过提供带有@CucumberOptions注释的“功能”选项(在 RunCucksTest 中)来更改它将查找功能文件的位置。例如,

@CucumberOptions(strict = true,  features = {
        "src/test/resources/cucumber/",
    },monochrome=true)

回答by David Ruan

  1. Set break points at where you want to trace in
  2. Right click on the Test Runner
  3. Select Debug as JUnit.
  1. 在要跟踪的位置设置断点
  2. 右键单击测试运行器
  3. 选择调试为 JUnit。