Skip to content

Instantly share code, notes, and snippets.

@iwein
Created October 11, 2016 09:30
Show Gist options
  • Select an option

  • Save iwein/e255104bc64e8a33fdd3868de5cced52 to your computer and use it in GitHub Desktop.

Select an option

Save iwein/e255104bc64e8a33fdd3868de5cced52 to your computer and use it in GitHub Desktop.
The anatomy of a good testcase
@Test
public void shouldWorkAccordingToInstructions() {
//given (instructor is a mock injected in a worker)
given(instructor.getInstructions()).willReturn(particularInstructions);
//when (operate the SUT)
ParticularResult result = workerUnderTest.work();
//then
then(instructor).should.getInstructions();
assertThat(result, is(createdAccordingTo(particularInstructions));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment