2

テストを実行してレポートを生成するために必要なすべてのライブラリが含まれている実行可能なJARに受け入れテストをパッケージ化したいと思います。また、すべてのテストまたは単一のテストを実行することもできます。実行可能なJARから単一のキュウリのシナリオを実行

これまではすべてのテストを実行できましたが、serenity.propertiesで指定した場所にレポートが生成されていても、index.htmlは生成されていません。

通常、私はserenity-maven-pluginを実行するmaven verify goalを使用してテストを実行しますが、JARから実行しているので、私は同じことをどのように達成できるかはわかりません。

@RunWith(CucumberWithSerenity.class) 
@CucumberOptions(features = "classpath:com/cfhayes/test/LookupADefinition.feature") 
public class DefinitionTestSuite { 
    public static void main(String[] args) throws Exception { 
    JUnitCore.main("com.cfhayes.test.DefinitionTestSuite"); 
    } 
} 

そして、私は単一のシナリオを指定することができるように私の機能ファイルを実行するためにタグを使用しています:

Feature: Lookup a definition 

    @TEST-0001 
    Scenario: Looking up the definition of 'apple' 
    Given the user is on the Wikionary home page 
    When the user looks up the definition of the word 'apple' 
    Then they should see the definition 'A common, round fruit produced by the tree Malus domestica, cultivated in temperate climates.' 

    @TEST-0002 
    Scenario: Looking up the definition of 'pear' 
    Given the user is on the Wikionary home page 
    When the user looks up the definition of the word 'pear' 
    Then they should see the definition 'An edible fruit produced by the pear tree, similar to an apple but elongated towards the stem.' 

を私が望んでいる

は、私は次のように見えるメインクラスを持っています実行可能なJARでJVM引数を使用してキュウリのオプションを設定できるようにする方法です。私は次のようなことを試みました:

java -jar my-test-jar.jar -Dcucumber.options="--tags @TEST-0001" 

...しかし、それでもすべてのテストが実行されます。

アイデアをいただければ幸いです。

+0

私は今すぐ必要なものです。あなたはどんな解決策も考え出しましたか? – yuva

+1

はい、私が持っていた問題は単純にコマンドライン引数の順序でした。 java -Ducucumber.options = " - tags @ TEST-0001" -jar my-test-jar.jar これ以外の変更は必要ありませんでした。 – cfhayes

+1

ここで実例を見て​​みましょう。 https://github.com/ch88251/cucumber-serenity-example – cfhayes

答えて

2

コマンドを構成する方法が間違っている可能性があります。キュウリのオプションは、javaオプションではなくcom.cfhayes.test.DefinitionTestSuite::mainの引数として取られます。これを試してください:

java -Dcucumber.options="--tags @TEST-0001" -jar my-test-jar.jar 

あなたのクラスの代わりにキュウリのオプションを処理してください。

+0

こんにちはMykola、あなたの提案は完璧に働いた。あなたの助けをありがとう! – cfhayes

+0

私の答えを受け入れることで質問を閉じたいと思うかもしれません。 –

関連する問題