-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAppTest.java
More file actions
37 lines (30 loc) · 1.1 KB
/
AppTest.java
File metadata and controls
37 lines (30 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package ratemate;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import javafx.scene.Parent;
public class AppTest {
@Test
public void testLoadFXMLValidFile() {
// Test that a valid FXML file can be loaded (without throwing an exception)
assertDoesNotThrow(() -> {
Parent root = App.loadFXML("primary"); // Assuming "primary.fxml" is a valid file
assertNotNull(root); // Make sure the returned root is not null
});
}
@Test
public void testLoadFXMLInvalidFile() {
// Test that loading a non-existent FXML file throws IOException
assertThrows(IOException.class, () -> App.loadFXML("nonexistent"));
}
@Test
public void testSetRootNullThrowsException() {
// Test setting root to null
assertThrows(NullPointerException.class, () -> App.setRoot(null));
}
@Test
public void testLaunchApplication() {
// Verify that launching the app doesn't throw exceptions
assertDoesNotThrow(() -> App.main(new String[]{}));
}
}