2016-09-12 9 views
0

JavaでCucumberとSeleniumを使ってポータブルなテストスイートを作成しようとしています。私は(私がより多くの機能を追加することを計画して)簡単な設定クラスJava内でCucumberOptions "features"を動的に設定する

public class FeatureConfig { 

private static String filePath = ""; 


public static String getFilePath() { 
    return filePath; 
} 

} 

を持っているそして、私のテストランナークラスがどのように見える

JPanel panel = new JPanel();  
    // adding panel to frame 
    frame.add(panel, BorderLayout.CENTER); 
    /* calling user defined method for adding components 
    * to the panel. 
    */ 
    placeComponents(panel); 
    //Set the size of the window 

    //Set the frame to appear in the center of the screen. 
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); 
    frame.setLocation(dim.width/2-frame.getSize().width/2, dim.height/2-frame.getSize().height/2); 

    // Setting the frame visibility to true 
    frame.setVisible(true); 

    System.out.println("Gonna Try to launch the test"); 
    RunCukeTests.main(args); 

:私のメインメソッドから私はこのような何かをやっていますこの:

@RunWith(Cucumber.class) 
//@Feature("my/package/**/*.feature") 
@CucumberOptions(

    //features= {"src/test/java/multiTest"} 
    features= {FeatureConfig.getFilePath() } 
, glue={"stepDefs"} 
, monochrome = true 
, plugin = {"pretty"} 
) 

public class RunCukeTests { 
    public static void main(String[] args) throws Exception {  
     System.out.println("This is a test"); 
     JUnitCore junit = new JUnitCore(); 
     Result result = junit.run(windowGui.RunCukeTests.class); 
    } 
} 

私はに実行している問題は、ラインである

features= {FeatureConfig.getFilePath() } 
私にエラー

The value for annotation attribute CucumberOPtions.feature must be a constant expression 

を与えている

これは、私は、コマンドラインを使用せずに、動的な機能のパスを設定することができないことを意味しないか、これを達成する方法はありますか?

答えて

0

フィーチャパスをダイナミックに設定する場合は、パラメータを正しく設定してメインメソッドcucumber.api.cli.Mainを実行する必要があります。

しかし、どうしてフィーチャーのパスを動的に変更する必要がありますか?私はそれについての質問は一度も見たことがなく、その方向性であなたを動かす要件が不思議です。

異なる時期に別の機能を実行する必要がありますか?その場合は、多分タグを使用すると助けになるかもしれません。

関連する問題