Skip to content

Instantly share code, notes, and snippets.

@woprzech
Created June 1, 2017 06:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save woprzech/1eb5dc8169d61c4e651a276b8acdb718 to your computer and use it in GitHub Desktop.
Save woprzech/1eb5dc8169d61c4e651a276b8acdb718 to your computer and use it in GitHub Desktop.
public class GradesServiceTest {
private Student student;
private Gradebook gradebook;
@Before
public void setUp() throws Exception {
gradebook = mock(Gradebook.class);
student = new Student();
}
@Test
public void calculates_grades_average_for_student() {
when(gradebook.gradesFor(student)).thenReturn(grades(8, 6, 10)); //stubbing gradebook
double averageGrades = new GradesService(gradebook).averageGrades(student);
assertThat(averageGrades).isEqualTo(8.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment