Search in sources :

Example 1 with JUnitTestReader

use of org.evosuite.junit.JUnitTestReader in project evosuite by EvoSuite.

the class JUnitTestParsedChromosomeFactory method readTestCase.

private Set<TestCase> readTestCase(String fileName) {
    JUnitTestReader parser = new JUnitTestReader();
    Set<TestCase> tests = new HashSet<TestCase>();
    System.out.print("* Parsing tests from " + fileName + ": ");
    tests.addAll(parser.readTests(fileName).values());
    System.out.println(". Parsed " + tests.size() + " test cases");
    return tests;
}
Also used : JUnitTestReader(org.evosuite.junit.JUnitTestReader) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with JUnitTestReader

use of org.evosuite.junit.JUnitTestReader in project evosuite by EvoSuite.

the class TestTestCaseExpander method testSomeAssignments.

@Test
public void testSomeAssignments() {
    Properties.PROJECT_PREFIX = "org.evosuite.testsuite";
    JUnitTestReader reader = new JUnitTestReader(null, new String[] { SRCDIR });
    TestCase testCase = reader.readJUnitTestCase(ArrayTestExample1.class.getName() + "#test2");
    testCase.clone();
    String code = testCase.toCode();
    TestCaseExpander expander = new TestCaseExpander();
    TestCase expandedTest = expander.expandTestCase(testCase);
    String expandedCode = expandedTest.toCode();
    Assert.assertEquals(testCase.size() + 14, expandedTest.size());
    Assert.assertFalse(code.equals(expandedCode));
}
Also used : TestCase(org.evosuite.testcase.TestCase) JUnitTestReader(org.evosuite.junit.JUnitTestReader) Test(org.junit.Test)

Example 3 with JUnitTestReader

use of org.evosuite.junit.JUnitTestReader in project evosuite by EvoSuite.

the class TestTestCaseExpander method testArrayAssignment.

@Test
public void testArrayAssignment() {
    Properties.PROJECT_PREFIX = "org.evosuite.testsuite";
    JUnitTestReader reader = new JUnitTestReader(null, new String[] { SRCDIR });
    TestCase testCase = reader.readJUnitTestCase(ArrayTestExample1.class.getName() + "#test5");
    testCase.clone();
    String code = testCase.toCode();
    TestCaseExpander expander = new TestCaseExpander();
    TestCase expandedTest = expander.expandTestCase(testCase);
    String expandedCode = expandedTest.toCode();
    Assert.assertEquals("Wrong length of test: " + expandedCode + ", original test: " + code, testCase.size() + 1, expandedTest.size());
    Assert.assertFalse(code.equals(expandedCode));
}
Also used : TestCase(org.evosuite.testcase.TestCase) JUnitTestReader(org.evosuite.junit.JUnitTestReader) Test(org.junit.Test)

Example 4 with JUnitTestReader

use of org.evosuite.junit.JUnitTestReader in project evosuite by EvoSuite.

the class TestTestCaseExpander method testOneAssignments.

@Test
public void testOneAssignments() {
    Properties.PROJECT_PREFIX = "org.evosuite.testsuite";
    JUnitTestReader reader = new JUnitTestReader(null, new String[] { SRCDIR });
    TestCase testCase = reader.readJUnitTestCase(ArrayTestExample1.class.getName() + "#test4");
    testCase.clone();
    String code = testCase.toCode();
    TestCaseExpander expander = new TestCaseExpander();
    TestCase expandedTest = expander.expandTestCase(testCase);
    String expandedCode = expandedTest.toCode();
    Assert.assertEquals("Wrong length of test: " + expandedCode + ", original test: " + code, testCase.size() + 2, expandedTest.size());
    Assert.assertFalse(code.equals(expandedCode));
}
Also used : TestCase(org.evosuite.testcase.TestCase) JUnitTestReader(org.evosuite.junit.JUnitTestReader) Test(org.junit.Test)

Example 5 with JUnitTestReader

use of org.evosuite.junit.JUnitTestReader in project evosuite by EvoSuite.

the class TestTestCaseExpander method testHiddenAssignments.

@Test
public void testHiddenAssignments() {
    Properties.PROJECT_PREFIX = "org.evosuite.testsuite";
    JUnitTestReader reader = new JUnitTestReader(null, new String[] { SRCDIR });
    TestCase testCase = reader.readJUnitTestCase(ArrayTestExample1.class.getName() + "#test3");
    testCase.clone();
    String code = testCase.toCode();
    TestCaseExpander expander = new TestCaseExpander();
    TestCase expandedTest = expander.expandTestCase(testCase);
    String expandedCode = expandedTest.toCode();
    Assert.assertEquals("Wrong length of test: " + expandedCode, testCase.size() + 24, expandedTest.size());
    Assert.assertFalse(code.equals(expandedCode));
}
Also used : TestCase(org.evosuite.testcase.TestCase) JUnitTestReader(org.evosuite.junit.JUnitTestReader) Test(org.junit.Test)

Aggregations

JUnitTestReader (org.evosuite.junit.JUnitTestReader)6 TestCase (org.evosuite.testcase.TestCase)5 Test (org.junit.Test)5 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1