New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(feat) JUnit: Add support classes, including an ApplicationTest
base test class.
#163
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Closed
This was referenced Dec 1, 2014
hastebrot
changed the title
feat(JUnit): Add JUnit support classes.
(feat) JUnit: Add JUnit support classes.
Feb 26, 2015
repositories {
jcenter()
}
dependencies {
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"
}
public class HelloWorldDemo extends Application {
@Override
public void start(Stage stage) {
Label label = new Label("Hello World!");
StackPane root = new StackPane(label);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.show();
}
}
public class HelloWorldDemoTest extends ApplicationTest {
@Override
public void start(Stage stage) {
Label label = new Label("Hello World!");
StackPane root = new StackPane(label);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.show();
}
@Test
public void should_contain_label() {
verifyThat(".label", hasText("Hello World!"));
}
} Use public class HelloWorldDemoTest extends ApplicationTest {
@Override
public void init() throws Exception {
FxToolkit.registerStage(() -> new Stage());
}
@Override
public void start(Stage stage) {
Label label = new Label("Hello World!");
StackPane root = new StackPane(label);
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.show();
}
@Override
public void stop() throws Exception {
FxToolkit.hideStage();
}
@Test
public void should_contain_label() {
verifyThat(".label", hasText("Hello World!"));
}
}
public class HelloWorldMain {
public static void main(String args) {
Application.launch(HelloWorldDemo.class, args);
}
}
public class HelloWorldMainTest {
@Before
public void setup() throws Exception {
ApplicationTest.launch(HelloWorldDemo.class);
}
@After
public void cleanup() throws Exception {
FxToolkit.cleanupStages();
}
@Test
public void should_contain_label() {
verifyThat(".label", hasText("Hello World!"));
}
} |
…ameters in favor of ApplicationFixture.
… `testfx-junit` dependency to the Gradle section.
hastebrot
changed the title
(feat) JUnit: Add JUnit support classes.
(feat) JUnit: Add support classes, including an Mar 2, 2015
ApplicationTest
base test class.
hastebrot
added a commit
that referenced
this pull request
Mar 4, 2015
(feat) JUnit: Add support classes, including an `ApplicationTest` base test class.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds some convenience classes for JUnit.
testfx-junit
.ApplicationTest
class, that will serve as counterpart to JavaFX'sApplication
. It launches the Toolkit per default and inherits methods fromFxRobot
.It will also include helpful classes for JUnitCategory
s andRule
s.