Search in sources :

Example 6 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class ProjectStaticDataTest method testIsToTest_LastestGenerationFailed.

@Test
public void testIsToTest_LastestGenerationFailed() {
    Project project = new Project();
    project.setTotalNumberOfTestableClasses(XSDUtils.convert(1));
    CUT cut = new CUT();
    cut.setFullNameOfTargetClass("foo.Bar");
    cut.setFullNameOfTestSuite("foo.BarTest");
    Generation generation = new Generation();
    generation.setId(XSDUtils.convert(0));
    generation.setFailed(true);
    cut.getGeneration().add(generation);
    project.getCut().add(cut);
    ProjectStaticData data = new ProjectStaticData();
    data.setProject(project);
    // if EvoSuite failed to generate a new test suite
    // for CUT and because we need to get N passing
    // generations to know whether the coverage improved
    // or not, this CUT has to be re-tested
    Assert.assertTrue(data.isToTest("foo.Bar", 3));
}
Also used : Project(org.evosuite.xsd.Project) Generation(org.evosuite.xsd.Generation) CUT(org.evosuite.xsd.CUT) Test(org.junit.Test)

Example 7 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class ProjectStaticDataTest method testIsToTest_ActuallyImproved.

@Test
public void testIsToTest_ActuallyImproved() {
    Project project = new Project();
    project.setTotalNumberOfTestableClasses(XSDUtils.convert(1));
    CUT cut = new CUT();
    cut.setFullNameOfTargetClass("foo.Bar");
    cut.setFullNameOfTestSuite("foo.BarTest");
    Generation g0 = new Generation();
    g0.setId(XSDUtils.convert(0));
    g0.setFailed(false);
    g0.setModified(true);
    g0.setTimeBudgetInSeconds(XSDUtils.convert(60));
    // empty dummy test suite
    g0.setSuite(new TestSuite());
    // add first generation
    cut.getGeneration().add(g0);
    for (int i = 1; i <= 3; i++) {
        Generation g = new Generation();
        g.setId(XSDUtils.convert(i));
        g.setFailed(false);
        g.setModified(false);
        g.setTimeBudgetInSeconds(XSDUtils.convert(60));
        g.setSuite(new TestSuite());
        cut.getGeneration().add(g);
    }
    project.getCut().add(cut);
    ProjectStaticData data = new ProjectStaticData();
    data.setProject(project);
    // coverage has improved
    Assert.assertTrue(data.isToTest("foo.Bar", 3));
}
Also used : Project(org.evosuite.xsd.Project) Generation(org.evosuite.xsd.Generation) CUT(org.evosuite.xsd.CUT) TestSuite(org.evosuite.xsd.TestSuite) Test(org.junit.Test)

Example 8 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class StorageManagerTest method testDefaultProjectInfo.

@Test
public void testDefaultProjectInfo() {
    StorageManager sm = new StorageManager();
    sm.clean();
    try {
        Project project = StorageManager.getDatabaseProject();
        Assert.assertNotNull(project);
    } finally {
        sm.clean();
    }
}
Also used : Project(org.evosuite.xsd.Project) Test(org.junit.Test)

Example 9 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class ProjectStaticDataTest method testIsToTest_NoCUTdata.

@Test
public void testIsToTest_NoCUTdata() {
    Project project = new Project();
    project.setTotalNumberOfTestableClasses(XSDUtils.convert(0));
    ProjectStaticData data = new ProjectStaticData();
    data.setProject(project);
    // there is not any generation for CUT,
    // so re-test it
    Assert.assertTrue(data.isToTest("foo.Bar", 3));
}
Also used : Project(org.evosuite.xsd.Project) Test(org.junit.Test)

Example 10 with Project

use of org.evosuite.xsd.Project in project evosuite by EvoSuite.

the class ProjectStaticDataTest method testIsToTest_OneLastNGenerationsFailed.

@Test
public void testIsToTest_OneLastNGenerationsFailed() {
    Project project = new Project();
    project.setTotalNumberOfTestableClasses(XSDUtils.convert(1));
    CUT cut = new CUT();
    cut.setFullNameOfTargetClass("foo.Bar");
    cut.setFullNameOfTestSuite("foo.BarTest");
    for (int i = 0; i < 5; i++) {
        Generation generation = new Generation();
        generation.setId(XSDUtils.convert(i));
        generation.setFailed(i % 2 != 0);
        generation.setModified(false);
        generation.setTimeBudgetInSeconds(XSDUtils.convert(60));
        cut.getGeneration().add(generation);
    }
    project.getCut().add(cut);
    ProjectStaticData data = new ProjectStaticData();
    data.setProject(project);
    // to be considered has improved, all N generations
    // have to end successfully
    Assert.assertTrue(data.isToTest("foo.Bar", 3));
}
Also used : Project(org.evosuite.xsd.Project) Generation(org.evosuite.xsd.Generation) CUT(org.evosuite.xsd.CUT) Test(org.junit.Test)

Aggregations

Project (org.evosuite.xsd.Project)11 Test (org.junit.Test)8 CUT (org.evosuite.xsd.CUT)5 Generation (org.evosuite.xsd.Generation)5 TestSuite (org.evosuite.xsd.TestSuite)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Schema (javax.xml.validation.Schema)1 SchemaFactory (javax.xml.validation.SchemaFactory)1