use of de.dagere.peass.testtransformation.JUnitTestShortener in project peass by DaGeRe.
the class TestShortening method testShorteningJUnit5Parameterized_methodItself.
@Test
public void testShorteningJUnit5Parameterized_methodItself() throws Exception {
final File test = new File(folder, "src/test/java/de");
test.mkdirs();
final File testClazz = new File(test, "ExampleTestJUnit5Parameterized.java");
try (JUnitTestShortener shortener = new JUnitTestShortener(transformer, folder, new ChangedEntity("de.ExampleTestJUnit5Parameterized", ""), "testMe")) {
Assert.assertFalse(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
try (FileInputStream inputStream = new FileInputStream(testClazz)) {
String fileContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
System.out.println(fileContent);
int matches = StringUtils.countMatches(fileContent, "@Test");
Assert.assertEquals(0, matches);
int matchesParameterized = StringUtils.countMatches(fileContent, "@ParameterizedTest");
Assert.assertEquals(1, matchesParameterized);
}
}
Assert.assertTrue(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
}
use of de.dagere.peass.testtransformation.JUnitTestShortener in project peass by DaGeRe.
the class TestShortening method testSubclassShortening.
@Test
public void testSubclassShortening() throws Exception {
final File test = new File(folder, "src/test/java/de");
test.mkdirs();
final File testClazz = new File(test, "ExampleTest.java");
final File subClazz = new File(test, "SubTest.java");
try (JUnitTestShortener shortener = new JUnitTestShortener(transformer, folder, new ChangedEntity("de.SubTest", ""), "test3")) {
Assert.assertFalse(FileUtils.contentEquals(exampleTestFile, testClazz));
Assert.assertFalse(FileUtils.contentEquals(subTestFile, subClazz));
}
Assert.assertTrue(FileUtils.contentEquals(exampleTestFile, testClazz));
Assert.assertTrue(FileUtils.contentEquals(subTestFile, subClazz));
}
use of de.dagere.peass.testtransformation.JUnitTestShortener in project peass by DaGeRe.
the class TestShortening method testShorteningJUnit5Parameterized.
@Test
public void testShorteningJUnit5Parameterized() throws Exception {
final File test = new File(folder, "src/test/java/de");
test.mkdirs();
final File testClazz = new File(test, "ExampleTestJUnit5Parameterized.java");
try (JUnitTestShortener shortener = new JUnitTestShortener(transformer, folder, new ChangedEntity("de.ExampleTestJUnit5Parameterized", ""), "checkSomething")) {
Assert.assertFalse(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
try (FileInputStream inputStream = new FileInputStream(testClazz)) {
String fileContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
System.out.println(fileContent);
int matches = StringUtils.countMatches(fileContent, "@Test");
Assert.assertEquals(1, matches);
int matchesParameterized = StringUtils.countMatches(fileContent, "@ParameterizedTest");
Assert.assertEquals(0, matchesParameterized);
}
}
Assert.assertTrue(FileUtils.contentEquals(exampleTestFile5Parameterized, testClazz));
}
use of de.dagere.peass.testtransformation.JUnitTestShortener in project peass by DaGeRe.
the class KoPeMeExecutor method runMethod.
protected void runMethod(final File logFolder, final TestCase test, final File moduleFolder, final long timeout) {
try (final JUnitTestShortener shortener = new JUnitTestShortener(testTransformer, moduleFolder, test.toEntity(), test.getMethod())) {
LOG.info("Cleaning...");
final File cleanFile = getCleanLogFile(logFolder, test);
clean(cleanFile);
final File methodLogFile = getMethodLogFile(logFolder, test);
runTest(moduleFolder, methodLogFile, test, test.getClazz(), timeout);
} catch (Exception e1) {
e1.printStackTrace();
}
}
use of de.dagere.peass.testtransformation.JUnitTestShortener in project peass by DaGeRe.
the class TestShortening method testShorteningJUnit5.
@Test
public void testShorteningJUnit5() throws Exception {
final File test = new File(folder, "src/test/java/de");
test.mkdirs();
final File testClazz = new File(test, "ExampleTestJUnit5.java");
try (JUnitTestShortener shortener = new JUnitTestShortener(transformer, folder, new ChangedEntity("de.ExampleTestJUnit5", ""), "checkSomething")) {
Assert.assertFalse(FileUtils.contentEquals(exampleTestFile5, testClazz));
try (FileInputStream inputStream = new FileInputStream(testClazz)) {
String fileContent = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
int matches = StringUtils.countMatches(fileContent, "@Test");
Assert.assertEquals(1, matches);
}
}
Assert.assertTrue(FileUtils.contentEquals(exampleTestFile5, testClazz));
}
Aggregations