/
LuvDyrachyo
/
Java_assignments
Обзор
Документация
Войти
/
LuvDyrachyo
/
Java_assignments
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
java-oop-ru/patterns/src/test/java/exercise/AppTest.java
48 строк
1 KB
@hexlet/cli
submit java-oop-ru/patterns
04 фев 2024, 15:38
04 фев 2024, 15:38
71e51f7
Код
Авторство
О чём код?
package exercise; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.Path; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.BeforeAll; class AppTest { private static String expectedInput; private static String expectedLabel; @BeforeAll public static void beforeAll() throws Exception { expectedInput = readFixture("input.html"); expectedLabel = readFixture("label.html"); } @Test void testInput() { TagInterface inputTag = new InputTag("submit", "Save"); var actual = inputTag.render(); assertThat(actual).isEqualTo(expectedInput); } @Test void testLabel() { TagInterface inputTag = new InputTag("submit", "Save"); TagInterface labelTag = new LabelTag("Press Submit", inputTag); var actual = labelTag.render(); assertThat(actual).isEqualTo(expectedLabel); } private static Path getFixturePath(String fileName) { return Paths.get("src", "test", "resources", "fixtures", fileName) .toAbsolutePath().normalize(); } private static String readFixture(String fileName) throws Exception { Path filePath = getFixturePath(fileName); return Files.readString(filePath).trim(); } }