【问题标题】:No JUnit tests found in Eclipse using Groovy + Cucumber在 Eclipse 中找不到使用 Groovy + Cucumber 的 JUnit 测试
【发布时间】:2012-07-07 17:10:13
【问题描述】:

我在 Groovy 中有一个 Cucumber 测试,如下所示

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

@RunWith(Cucumber.class)
@Options(features = ["classpath:CarDrive.feature"])
public class FuelCarTest {

}

import cucumber.annotation.en.Given
import cucumber.annotation.en.Then
import cucumber.annotation.en.When

public class FuelCarSteps {

    public FuelCarSteps() {
        println "FuelCarSteps::FuelCarSteps"
    }

    @Given("I have a car")
    def givenCar() {
        println "I have a car"
    }

    @When("^you fill it with 50 litres of fuel")
    def addFuel() {
        println "add fuel"
    }

    @Then("^the tank contains 60 litres")
    def checkBalance() {
        println "TODO: add check here"
    }
}

我可以使用 mvn test 很好地运行测试,但是当我尝试在 Eclipse 中运行它时,我得到了

No JUnit tests found

尝试清理、重建和重新启动

【问题讨论】:

    标签: eclipse groovy junit cucumber


    【解决方案1】:

    您好,您需要为 junit 中的每个测试创建运行配置

    在运行配置的类输入中提供完整路径(如package1.subpackege1.testclassname

    【讨论】:

      【解决方案2】:

      控制,如果您在 Groovy 代码中有任何错误,例如 Type of expression is statically unknown: 或类似的。它们不会像往常一样炫耀错误,而且几乎不可见。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-12-02
        • 1970-01-01
        • 1970-01-01
        • 2018-03-24
        • 1970-01-01
        • 2011-03-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多