15

Cucumber テスト用に Eclipse で Maven プロジェクトを実行しています。私のテスト ランナー クラスは次のようになります。

@RunWith(Cucumber.class)
@CucumberOptions(
        tags = { "@Now" },      
//      tags = { "@Ready" },
//      tags = { "@Draft" },
        features = { "src/test/java/com/myCompany/FaultReporting/Features" },
        glue = { "com.myCompany.myApp.StepDefinitions" }
        )
public class RunnerTest {   
}

タグをテスト ランナーにハード コードする代わりに、.command ファイルを使用して渡したいと考えています。(つまり System.getProperty("cucumber.tag") を使用)

ただし、上記のテスト ランナーに次のコード行を追加すると、エラーが発生します。

@RunWith(Cucumber.class)
@CucumberOptions(
        tags = { System.getProperty("cucumber.tag") }
//      tags = { "@Now" },      
//      tags = { "@Ready" },
//      tags = { "@Draft" },
        features = { "src/test/java/com/myCompany/FaultReporting/Features" },
        glue = { "com.myCompany.myApp.StepDefinitions" }
        )
public class RunnerTest {   
}

私が得るエラーは次のとおりです。「注釈属性CucumberOptions.tagsの値は定数式でなければなりません」。

したがって、パラメータ化された値ではなく、定数のみが必要なようです。これを回避する賢い方法を知っている人はいますか?

4

2 に答える 2