5

Cucumber-JVM と Selenium WebDriver を一緒に使用しています。Eclipse に Maven プロジェクトがあり、pom.xml ファイルの依存関係は次のとおりです。

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

RunCukesTest.java ファイルの内容は次のとおりです。

import org.junit.runner.RunWith;
import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})
public class RunCukesTest {
}

次のコード行でエラーが発生します。

import cucumber.junit.Cucumber;
@RunWith(Cucumber.class)
@Cucumber.Options(format = {"pretty", "html:target/cucumber-htmlreport","json-pretty:target/cucumber-report.json"})

しかし、バージョン 1.0.14 を使用すると、うまく動作します。最新バージョンの何が問題になっていますか?

4

7 に答える 7

9

@Cucumber.Options代わりに使用することは推奨されていません@CucumberOptions

@CucumberOptions(
    format = "pretty",
    features = "//refer to Feature file"  
)

これがお役に立てば幸いです

于 2015-07-08T09:30:06.250 に答える
5

注釈は次のように変更されました@CucumberOptions:

そして、このきゅうりバージョンにjson-pretty変わったと思います。json

これはうまくいくはずです:

@CucumberOptions(
      format = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}
)

また、cucumber-jvm の仕様によると、 format は非推奨です。に置き換える必要がありpluginます。これも機能するはずです:

plugin = {"pretty", "html:target/cucumber-htmlreport","json:target/cucumber-report.json"}

それが役に立てば幸い

于 2015-07-08T09:29:56.137 に答える
3

キュウリ 1.2.2

<cucumber.version>1.2.2</cucumber.version>
....
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>info.cukes</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>${cucumber.version}</version>
        <scope>test</scope>
    </dependency>
....

ここにサンプルの動作テストがあります:

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = "classpath:features/myfeature.feature", tags = "@Mytag", plugin = {"pretty", "html:target/cucumber"})
public class MYAcceptanceTest {

}

cucumber.api.junit.Cucumberインポートは代わりにcucumber.junit.Cucumberあり、キュウリオプションのインポートを追加する必要があることに注意してください。オプションのステレオタイプは、@CucumberOptions代わりに@Cucumber.Options

于 2015-07-08T09:30:47.017 に答える
1

RunCukesTest.java ファイルと Feature ファイルの両方を同じフォルダーまたはパッケージに入れてみてください。

于 2016-10-15T22:27:11.733 に答える