Skip to content

Instantly share code, notes, and snippets.

@gbzarelli
Created July 30, 2020 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbzarelli/74573f10449f2a248aa36bbc0bd36d3a to your computer and use it in GitHub Desktop.
Save gbzarelli/74573f10449f2a248aa36bbc0bd36d3a to your computer and use it in GitHub Desktop.
Used in Medium article about Tests
@SpringBootTest
@DataJpaTest
class PersonRepositoryIntegrationTest {
@Autowired
private PersonRepository subject;
@AfterEach
void tearDown() throws Exception {
subject.deleteAll();
}
@Test
void shouldSaveAndFetchPerson() throws Exception {
Person peter = new Person("Peter", "Pan");
subject.save(peter);
Optional<Person> maybePeter = subject.findByLastName("Pan");
assertThat(maybePeter, is(Optional.of(peter)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment