Created
July 30, 2020 01:51
-
-
Save gbzarelli/ca01ddcf1026cf57524400e26a8e4b3e to your computer and use it in GitHub Desktop.
Used in Medium article about Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | |
class SampleE2ETests { | |
@Autowired | |
private TestRestTemplate restTemplate; | |
@Autowired | |
private PersonRepository personRepository; | |
@AfterEach | |
void tearDown() throws Exception { | |
personRepository.deleteAll(); | |
} | |
@Test | |
void exampleTest() { | |
Person peter = new Person("Peter", "Pan"); | |
personRepository.save(peter); | |
String body = restTemplate.getForObject("/hello/Pan", String.class); | |
assertThat(body).isEqualTo("Hello Peter Pan!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment