Skip to content

Commit 688f066

Browse files
committed
test: added first test
Signed-off-by: Rajdeep Roy Chowdhury <rrajdeeproychowdhury@gmail.com>
1 parent 855998f commit 688f066

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,22 @@ dependencies {
2727

2828
testCompileOnly 'org.projectlombok:lombok:1.18.20'
2929
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
30+
31+
testImplementation 'org.testfx:testfx-junit5:4.0.18'
32+
testImplementation 'org.testfx:openjfx-monocle:jdk-12.0.1+2'
33+
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
34+
testImplementation 'org.hamcrest:hamcrest:2.2'
3035
}
3136

3237
javafx {
3338
version = "17"
3439
modules = [ 'javafx.controls', 'javafx.fxml', 'javafx.graphics', 'javafx.base' ]
3540
}
3641

42+
test {
43+
useJUnitPlatform()
44+
}
45+
3746
spotless {
3847
java {
3948
lineEndings 'WINDOWS'

src/main/resources/satyamconsignment/ui/Input/BillEntry/BillEntry.fxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<TabPane layoutX="41.0" layoutY="87.0" prefHeight="633.0" prefWidth="717.0"
1414
tabClosingPolicy="UNAVAILABLE" style="-fx-tab-min-width: 120px; -fx-tab-max-width: 120px;">
1515
<tabs>
16-
<Tab text="Add" closable="false">
16+
<Tab fx:id="TabButtonAdd" text="Add" closable="false">
1717
<content>
1818
<fx:include fx:id="AddBill" source="AddBill/AddBill.fxml"/>
1919
</content>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package functional;
2+
3+
import javafx.fxml.FXMLLoader;
4+
import javafx.scene.Parent;
5+
import javafx.scene.Scene;
6+
import javafx.stage.Stage;
7+
import org.junit.jupiter.api.Test;
8+
import org.testfx.framework.junit5.ApplicationTest;
9+
import org.testfx.matcher.base.NodeMatchers;
10+
11+
import static org.testfx.api.FxAssert.verifyThat;
12+
13+
public class BillEntryTest extends ApplicationTest {
14+
15+
@Override
16+
public void start(Stage stage) throws Exception {
17+
FXMLLoader loader = new FXMLLoader(
18+
getClass().getResource("/satyamconsignment/ui/Main/Main.fxml")
19+
);
20+
21+
Parent root = loader.load();
22+
stage.setScene(new Scene(root));
23+
stage.setMaximized(true);
24+
stage.show();
25+
}
26+
27+
@Test
28+
void testIfLoadedProperly() {
29+
clickOn("#input_btn");
30+
31+
verifyThat("#bill_entry_btn", NodeMatchers.isVisible());
32+
clickOn("#bill_entry_btn");
33+
34+
verifyThat("#TabButtonAdd", NodeMatchers.isVisible());
35+
clickOn("#TabButtonAdd");
36+
37+
verifyThat("#supplier_field", NodeMatchers.isVisible());
38+
// clickOn("#supplier_field");
39+
40+
interact(() -> {
41+
lookup("#supplier_field").queryTextInputControl().setText("ajanta");
42+
});
43+
44+
45+
verifyThat("#buyer_name_field", NodeMatchers.isVisible());
46+
clickOn("#buyer_name_field");
47+
48+
write("hello");
49+
}
50+
51+
52+
}

0 commit comments

Comments
 (0)