Reputation: 771
I built a simple calculator with JavaFX, now I want to test it and it is proving to be quite a challenge. I found out about a library called TestFX which seems to be perfect for testing my calculator. After adding the following dependencies:
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-core</artifactId>
<version>4.0.13-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit</artifactId>
<version>4.0.13-alpha</version>
<scope>test</scope>
</dependency>
as stated in ther GitHub repo, however functions like clickOn(), rightClickOn(), write(), push() and so on... are not recognized like they are supposed to be as per the examples provided in their GitHub repo.
Here are all my project dependencies:
Here is what I'm trying to do:
public class CalcTDDTests extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent mainNode = FXMLLoader.load(getClass().getResource("/fxml/FXMLDocument.fxml"));
mainNode.getStylesheets().add("styles/myStyles.css");
primaryStage.setScene(new Scene(mainNode));
primaryStage.show();
primaryStage.toFront();
}
@Test
public void testPressDigit() {
clickOn("#nineBtn");
}
}
I am using NetBeans 8.2 and if this is a matter of importing some package, NetBeans is not finding it. I tried to import the following packages:
import static org.testfx.api.FxAssert.verifyThat;
import static org.testfx.matcher.control.LabeledMatchers.hasText;
import org.testfx.framework.junit.ApplicationTest;
import org.testfx.robot.Motion;
I'm using JDK 1.8 and JavaFX 8
Upvotes: 0
Views: 1452
Reputation: 82461
CalcTDDTests
extends javafx.application.Application
. This class does not contain any of the methods you're looking for.
The class containing those methods is org.testfx.framework.junit.ApplicationTest
. You need to extend this class instead of javafx.application.Application
.
public class CalcTDDTests extends ApplicationTest {
...
}
Upvotes: 1