Mercurial > hg > SpringPlayground
diff spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java @ 11:f3f9102ef7c0
Noch ein Test mit der in-memory Datenbank: diesmal wird ein Testdatensatz vorher rein geladen, der dann im Test geholt wird.
author | Dirk Olmes <dirk.olmes@codedo.de> |
---|---|
date | Thu, 13 Aug 2020 17:33:20 +0200 |
parents | 7ce4367b50bc |
children | 4594ff529ab1 |
line wrap: on
line diff
--- a/spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java Thu Aug 13 17:17:45 2020 +0200 +++ b/spring-boot-playground/src/test/java/de/comline/spring/service/MovieServiceTestWithMockRepo.java Thu Aug 13 17:33:20 2020 +0200 @@ -5,6 +5,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -12,6 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.test.annotation.DirtiesContext; import de.comline.spring.entity.Movie; import de.comline.spring.repository.MovieRepository; @@ -21,6 +23,7 @@ MovieService.class, TestConfig.class }) +@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD) public class MovieServiceTestWithMockRepo { @Autowired private MovieService service;