Wed, 06 Sep 2023 21:08:04 +0200
add RegressionTest - fixes #264
package de.unixwork.uwproj; import org.junit.jupiter.api.Test; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; import static org.junit.jupiter.api.Assertions.assertEquals; public class RegressionTest { private void goldenSampleTest(String xml, String gs) throws Exception { final var contents = new ByteArrayOutputStream(); try (var out = new BufferedWriter(new OutputStreamWriter(contents))) { Main.writeConfigureScript(out, "test/make/configure.vm", Main.loadProjectFile("test/make/" + xml)); } assertEquals( Files.readString(Path.of( Objects.requireNonNull(RegressionTest.class.getClassLoader().getResource("golden-sample/" + gs)).toURI() )), contents.toString(StandardCharsets.UTF_8) ); } @Test void projectXmlOutput() throws Exception { goldenSampleTest("project.xml", "configure"); } @Test void project2XmlOutput() throws Exception { goldenSampleTest("project2.xml", "configure2"); } }