/
NikolayIvkin
/
tutorials1
Обзор
Документация
Войти
/
NikolayIvkin
/
tutorials1
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
testing-modules/spring-testing-2/src/test/java/com/baeldung/dynamicproperties/ArticleTestFixtureLiveTest.java
38 строк
1 KB
Haroon Khan
[JAVA-8703] Fix Live test to allow isolated execution
02 дек 2021, 01:41
02 дек 2021, 01:41
1ff29cf
Код
Авторство
О чём код?
package com.baeldung.dynamicproperties; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest @ActiveProfiles("pg") @ExtendWith(PostgreSQLExtension.class) @DirtiesContext public class ArticleTestFixtureLiveTest { @Autowired private ArticleRepository articleRepository; @Test void givenAnArticle_whenPersisted_thenShouldBeAbleToReadIt() { Article article = new Article(); article.setTitle("A Guide to @DynamicPropertySource in Spring"); article.setContent("Today's applications..."); articleRepository.save(article); List<Article> allArticles = articleRepository.findAll(); assertThat(allArticles).hasSize(1); Article persisted = allArticles.get(0); assertThat(persisted.getTitle()).isEqualTo("A Guide to @DynamicPropertySource in Spring"); assertThat(persisted.getContent()).isEqualTo("Today's applications..."); } }