2

我在 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

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

4

2 回答 2

0

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

于 2013-04-09T07:38:16.540 回答
0

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

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

于 2012-07-16T10:31:50.640 回答