This test should check that the correct student is displayed when the user searches for a student via their student ID.
You will need to stub the getById
method since that is the method that the <
setUp
method and looks like:
Student jack = new Student(1111, "Jack", "Chemistry"); when(dao.getByID(1111)).thenReturn(jack);
This stub will only return the student jack
when the ID 1111
is passed to the getById
method. The purpose of these stub methods is to do provide the bare minimum functionality that allows the test to operate, using hard-coded data that can be checked in the test.
The robot will need to enter the student's ID (use the ID that the getById
stub expects) into the search box, and click the <
You can find the component names on lines 26--28 in the constructor for StudentViewer
.
Since the getById
method should have been called when the button was clicked, the test should verify that this is the case and that the correct parameter was passed. The code for this looks like:
verify(dao).getById(1111);
The test should then check that the list is displaying the correct student. This code is similar to the code that you used in the previous test, except there will only be one student.