-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTest.java
More file actions
45 lines (38 loc) · 1.47 KB
/
Test.java
File metadata and controls
45 lines (38 loc) · 1.47 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
38
39
40
41
42
43
44
45
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
//basic junit tests tbh
//testing for Main --- intersection of all sub/inhereted classes.
class Test {
private Main main;
@BeforeEach
void setUp() {
main = new Main(); //main instance
}
@Test
void testStatusLabelNotNull() { //label for GUI
JLabel statusLabel = main.getStatusLabel();
assertNotNull(statusLabel);
}
@Test
void testActionPerformed_Student() { //Student check
JButton studentButton = new JButton();
studentButton.setActionCommand("Student");
main.actionPerformed(new ActionEvent(studentButton, ActionEvent.ACTION_PERFORMED, "Student"));
String expectedText = "Please select your status:";
assertEquals(expectedText, main.getStatusLabel().getText());
}
@Test
void testActionPerformed_Educator() {//Educator Check
JButton educatorButton = new JButton();
educatorButton.setActionCommand("Educator");
main.actionPerformed(new ActionEvent(educatorButton, ActionEvent.ACTION_PERFORMED, "Educator"));
String expectedText = "Please select your status:";
assertEquals(expectedText, main.getStatusLabel().getText());
}
}