“设置黄瓜选项”;特色;在Java中从内部动态地
我正试图用Cucumber和Selenium在Java中创建一个可移植的测试套件。根据我的主要方法,我做了如下工作:“设置黄瓜选项”;特色;在Java中从内部动态地,java,selenium,junit,cucumber,cucumber-jvm,Java,Selenium,Junit,Cucumber,Cucumber Jvm,我正试图用Cucumber和Selenium在Java中创建一个可移植的测试套件。根据我的主要方法,我做了如下工作: JPanel panel = new JPanel(); // adding panel to frame frame.add(panel, BorderLayout.CENTER); /* calling user defined method for adding components * to the panel. */
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);
}
}
我有一个简单的config类(我计划在其中添加更多函数)
我的TestRunner类如下所示:
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
这是否意味着我不能在不使用命令行的情况下动态设置特性路径,或者有什么方法可以实现这一点 如果要动态设置功能路径,我认为您必须在正确设置参数的情况下执行
cucumber.api.cli.main
中的main方法
但是,为什么需要动态更改功能的路径?我从来没有看到过关于这方面的问题,我对驱使你朝这个方向前进的需求感到好奇
您是否需要在不同的时间执行不同的功能?如果是这样,也许使用标签可以帮助您。您找到解决此问题的方法了吗?