Java 将TestFX与Cucumber一起使用
我正在尝试将Cucumber与TestFX结合使用,但无法从应用程序中获取任何节点 我有另一类TestFX,它工作得很好,还有另一类cumber,它也工作得很好。但是我越来越 org.loadui.testfx.exceptions.NoNodesFoundException:没有匹配“TextInputControl有文本您能找到此标签”的节点 TestFXBase: 跑步者: 特色: 特征:标签文本存在吗 场景:你能找到这个标签文本吗 既然如此,你能找到这个标签存在吗 那哪个好呢 因此,参数已传递,但TestFX不会在我的cucumber runner中启动应用程序,只是尝试查找节点。有一个类扩展了TestFXBase并且工作得很好。我如何解决这个问题 编辑:我的依赖项是Java 将TestFX与Cucumber一起使用,java,javafx,cucumber,testfx,Java,Javafx,Cucumber,Testfx,我正在尝试将Cucumber与TestFX结合使用,但无法从应用程序中获取任何节点 我有另一类TestFX,它工作得很好,还有另一类cumber,它也工作得很好。但是我越来越 org.loadui.testfx.exceptions.NoNodesFoundException:没有匹配“TextInputControl有文本您能找到此标签”的节点 TestFXBase: 跑步者: 特色: 特征:标签文本存在吗 场景:你能找到这个标签文本吗 既然如此,你能找到这个标签存在吗 那哪个好呢 因此,参数
这里的解决方案是将SetupHeadleMode和setUpClass方法的内容移动到TestFXBase类初始值设定项:
static {
if (isHeadless) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
try {
ApplicationTest.launch(Main.class);
} catch (Exception e) {
// oh no
}
}
是的,我在github上得到了同样的答案
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import org.junit.Test;
public class MyStepdefs extends TestFXBase {
@Test
@Given("^That \"([^\"]*)\" Exists$")
public void thatExists(String arg0) throws Throwable {
rightClickOn("#rect");
}
@Test
@Then("^Which is \"([^\"]*)\"$")
public void whichIs(String arg0) throws Throwable {
System.out.println(arg0);
}
}
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(plugin = { "pretty" })
public class MyRunner extends TestFXBase{}
<dependency>
<groupId>org.loadui</groupId>
<artifactId>testFx</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>openjfx-monocle</artifactId>
<version>1.8.0_20</version>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.6-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
<version>4.0.6-alpha</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
<scope>test</scope>
</dependency>
static {
if (isHeadless) {
System.setProperty("testfx.robot", "glass");
System.setProperty("testfx.headless", "true");
System.setProperty("prism.order", "sw");
System.setProperty("prism.text", "t2k");
System.setProperty("java.awt.headless", "true");
}
try {
ApplicationTest.launch(Main.class);
} catch (Exception e) {
// oh no
}
}