Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epacoverage #249

Open
wants to merge 149 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
149 commits
Select commit Hold shift + click to select a range
8843f1a
Inital commit for EPA coverage
crazy2k Dec 1, 2015
24309d3
Add (non-functional) EPA coverage criteria
crazy2k Dec 3, 2015
909c74e
Allow EPACoverageFitness#getFitness to display a basic stacktrace of …
crazy2k Dec 20, 2015
47e97b9
Add EPA XML constructor
crazy2k Dec 30, 2015
ae0f02c
Add EPATrace constructor
crazy2k Dec 30, 2015
cb1a024
Complete missing methods in EPA-related classes
crazy2k Dec 31, 2015
3334349
Simulate until MethodCall.endState is implemented
crazy2k Dec 31, 2015
d7a2001
Tune EPA classes
crazy2k Jan 4, 2016
364cb1e
Add EPACoverageTest
crazy2k Jan 4, 2016
0c81ef7
Comment out EPA in getFitnessFactory()
crazy2k Jan 4, 2016
4105799
Only consider actions that are in the EPA
crazy2k Jan 4, 2016
12c64da
new EvoSuite property EPA_XML_PATH
Jan 5, 2016
e2d7f00
new EPA Factory
Jan 5, 2016
d2ce252
new unit test case for EPA coverage
Jan 5, 2016
083e8df
refactor: EPA is now EPATRANSITION
Jan 6, 2016
57d38d3
changes to ListItr test subject
Jan 6, 2016
37f244c
unit test case with execution traces
Jan 7, 2016
0572997
Bounded Stack source code
Jan 7, 2016
045819b
refactor: minor changes
Jan 7, 2016
68fcf55
EPA Unit Test Cases
Jan 7, 2016
ddc5375
EPA Unit Test Cases
Jan 7, 2016
32556c7
test case for MyBoundedStack
Jan 7, 2016
5af2716
EPA Unit Test
Jan 7, 2016
6e040f0
revert
Jan 7, 2016
efd6332
Stack: more unit test cases
Jan 7, 2016
4d6707c
EPATransitionCoverageFactory is finished
Jan 7, 2016
88bb5fe
Unit test for 2 object instances
Jan 7, 2016
cf7c91b
Make EPATraceFactory get destination states from trace
crazy2k Jan 9, 2016
c67f959
Instrumentate ListItr
crazy2k Jan 9, 2016
e05b77a
Merge branch 'epacoverage' of github.com:crazy2k/evosuite into epacov…
crazy2k Jan 9, 2016
f31499e
Adapt code the EPATransitionCoverageGoal to new behaviour
crazy2k Jan 9, 2016
19a7060
Fix code that calculates fitness
crazy2k Jan 9, 2016
1202ee5
Change MyBoundedStack state names to match XML
crazy2k Jan 9, 2016
2bdf4a7
Remove old comments
crazy2k Jan 9, 2016
53e7331
ListItr has 69 edges instead of 37
Jan 11, 2016
2989ff9
EPATraceBuilder now creates traces using className also
Jan 11, 2016
fb70b04
using only one ListItr.xml
Jan 11, 2016
d196ba8
bugfix: reportState117() -> reportStateS117()
Jan 11, 2016
3b642fa
removing logging
Jan 11, 2016
0aa8af9
missing updateIndividual() in EPATransitionCovergaeSuiteFitness
Jan 13, 2016
dafc70e
bugfix: TooManyResourcesException is expected to be handled in execut…
Jan 13, 2016
6c8b10b
Minimisation now works
Jan 13, 2016
65549be
EPA is checked against Target class when it is built
Jan 13, 2016
f3f7ebc
refactor: separate system tests for ListItr
Jan 13, 2016
9c33ebb
fixing reported coverage goals
Jan 14, 2016
a23fd74
bugfix: incorrect result for getNumOfNotCoveredGoals()
Jan 14, 2016
0df0aeb
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 15, 2016
cc3a0af
commit after merge
Jan 15, 2016
3262e1e
unneeded settings
Jan 20, 2016
04c83e7
EPATRANSITION is not a default criterion
Jan 20, 2016
ce16ab5
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 20, 2016
ebeacb4
small fix
Jan 20, 2016
3ad665a
Setting correct coverage values
Jan 28, 2016
08a003b
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 28, 2016
7f3dc22
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 29, 2016
0ca4308
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 29, 2016
a9f9270
Merge https://github.com/EvoSuite/evosuite into epacoverage
Jan 29, 2016
e1b2710
new option
Feb 1, 2016
3723fc2
Merge https://github.com/EvoSuite/evosuite into epacoverage
Feb 10, 2016
7391f60
Merge https://github.com/EvoSuite/evosuite into epacoverage
Feb 11, 2016
775940f
Merge https://github.com/EvoSuite/evosuite into epacoverage
Feb 12, 2016
816ec6c
Add EPACoverageFromTraceFileAnalyzer
crazy2k Feb 22, 2016
9e4b9d4
Add test for samples for EPACoverageFromTraceFileAnalyzer
crazy2k Feb 27, 2016
d0b6c2a
Make EPACoverageFromTraceFileAnalyzer print output to specified file
crazy2k Feb 27, 2016
2dc9781
commit after merge
Mar 16, 2016
08f4ba5
Merge https://github.com/EvoSuite/evosuite into epacoverage
Mar 18, 2016
aed54bb
new EPATraceObserver
Mar 18, 2016
78aa1bc
new instrumentation ready
Mar 18, 2016
da8efa3
unmatching EPA traces are discarded
Mar 18, 2016
269da3c
bugfix: isState() method is looked in any superclass
Mar 18, 2016
b46f7b0
Add support for @EpaState
crazy2k Mar 21, 2016
e1876ca
EPATraceObserver is replaced by actual ASM instrumentation
Mar 21, 2016
dcaf890
disabling access private members and funciontal mocking to EPA system…
Mar 21, 2016
0cebfe8
new @EpaAction is implemented
Mar 21, 2016
a409050
Merge https://github.com/EvoSuite/evosuite into epacoverage
Mar 21, 2016
3770622
bugfix: checking EPA action is correctly defined
Mar 21, 2016
01e8fa1
EPA Monitor checks EPA state before appending
Mar 21, 2016
a9dbb57
throw an EvosuiteError when an disconnected trace is observed
Mar 22, 2016
5a66b36
Merge https://github.com/EvoSuite/evosuite into epacoverage
Mar 23, 2016
26d8986
Merge https://github.com/EvoSuite/evosuite into epacoverage
Mar 28, 2016
ef6118e
Merge https://github.com/EvoSuite/evosuite into epacoverage
Mar 28, 2016
b431937
EPATraceObserver is replaced by ExecutionTrace
Mar 28, 2016
bb4b007
testfix: error in expected covered transitions
Mar 28, 2016
fadc67b
@EpaState and @EpaAction annotations are included in the evosuite jar…
Apr 26, 2016
e0bd065
commit after merge
Apr 26, 2016
30114c9
Initial changes for EPAERROR criterion
crazy2k Aug 6, 2016
bbcb782
Add EPASuiteFitness
crazy2k Aug 6, 2016
6f1af34
WIP: Refactoring
crazy2k Aug 11, 2016
6d10957
WIP: Add basic code fore EPAError criterion
crazy2k Aug 16, 2016
84d778f
Add EPAERROR criterion
crazy2k Aug 20, 2016
dc5b98b
Fix tests for EPAError
crazy2k Aug 20, 2016
577a218
Add test for EPAError
crazy2k Aug 20, 2016
763d41b
Fix support for EPAERROR
crazy2k Sep 10, 2016
47e8597
WIP: Make tests fail when EPA Error is found
crazy2k Sep 10, 2016
5f37484
Make TestSuiteWriter aware of EPA errors
crazy2k Sep 17, 2016
7f39e49
compareClassName() when TestFitnessFunction is of different type
crazy2k Feb 12, 2017
80f4833
Don't break if invalid state found
crazy2k Apr 2, 2017
099be0d
the option print_missed_goals works also when -measureCoverage
Apr 26, 2017
9e0d869
only instrument with enter/exit call backs methods with @EpaAction an…
Apr 26, 2017
36c31fc
report missing action name when malformed trace is found
Apr 26, 2017
12ef9aa
code style: explicit {}
Apr 26, 2017
91f78d4
new fields of the @EpaActin annotation to capture exceptions
Apr 27, 2017
88af848
Instrumentation explicitly records the exception object when an expec…
Apr 27, 2017
6940e86
the EPA monitor handles actions with valid exceptions
Apr 27, 2017
6df0e46
bugfix: check if the constructor call has thrown an exception before …
Jun 1, 2017
866b54b
hotfix for not using the @EvoRunner dependency
Jun 7, 2017
b1cffbb
getTraceNoFinishCalls() instead of getTrace() in the EPAMonitor
Jul 13, 2017
ac2a1f5
Comment lines in EPAMonitor about previous state
crazy2k Jul 23, 2017
4c0dbe9
Change comparison in EPATransitionCoverageTestFitness
crazy2k Jul 23, 2017
7b18d6e
Merge branch 'epacoverage' of github.com:crazy2k/evosuite into epacov…
crazy2k Jul 23, 2017
66b5570
Add fail()
crazy2k Jul 23, 2017
a9c2b85
Invalid transition tests do not fail anymore
Aug 2, 2017
65c737a
changes in variable names
jgaleotti Jun 9, 2018
cc17c80
printed goals
jgaleotti Jun 9, 2018
316d45d
Dot and XML printers
jgaleotti Jun 9, 2018
3bcbba7
Dot and XML printers
jgaleotti Jun 9, 2018
c393e5d
testfix: missing @EpaAction and @EpaState
jgaleotti Jun 9, 2018
f4ea29b
EPA traces can have invalid states (if queries are not successful)
jgaleotti Jun 9, 2018
bddda84
Exceptional and Normal EPA transitions are introduced
jgaleotti Jun 9, 2018
aa575ae
Exceptional transitions are recorded
jgaleotti Jun 9, 2018
9d86b47
new test case for exceptional EPA traces
jgaleotti Jun 9, 2018
6af825d
new test case for exceptional transition of MiniBoundedStack
jgaleotti Jun 9, 2018
92687c2
new XML for MiniBoundedStack
jgaleotti Jun 9, 2018
74011c2
refactor EPA transition and EPA error coverages
jgaleotti Jun 9, 2018
a12c39f
new criterion EPAEXCEPTION coverage
jgaleotti Jun 11, 2018
a85cac7
new test case for EPA exception coverage
jgaleotti Jun 11, 2018
3090258
new criteria for mining EPAs, EPAMINING
jgaleotti Jun 21, 2018
1642ae1
test moved to test folder
jgaleotti Jun 21, 2018
9e9e858
Archive works for EPA mining coverage criterion
jgaleotti Jun 22, 2018
9aab912
new property INFERRED_EPA_XML_PATH to write the inferred EPA
jgaleotti Jun 27, 2018
71ef784
placeholders for EPAADJACENTEDGES coverage
jgaleotti Jul 2, 2018
cfa6744
epaadjacentedges coverage
j-godoy Jul 4, 2018
aedfb28
epaadjacentedges coverage
j-godoy Jul 4, 2018
79e0877
change goal name epaadjacentedges
j-godoy Jul 6, 2018
41f028b
refactor: renaming and fitness for EPA adjacent edges
jgaleotti Jul 10, 2018
77a42c0
add exceptional transitions as goals in adjacentedges
j-godoy Jul 11, 2018
86731f2
change fitness function in epaadjacentedges
j-godoy Jul 12, 2018
c309e4e
change fitness function for EPAExceptionCoverageSuiteFitness
j-godoy Jul 12, 2018
61c8c97
implement compareTo method in EPAExceptionCoverageTestFitness
j-godoy Jul 17, 2018
9188fc8
EPAAdjacentEdges generated goals on demand, the full list is never fu…
jgaleotti Jul 30, 2018
ab7ea66
EPAAdjacentEdges generated goals on demand but Total_goals is calcula…
j-godoy Aug 2, 2018
f826739
dont remove some invalid assertions
j-godoy Aug 8, 2018
151245d
merge with 1.0.7 snapshot
jgaleotti Nov 3, 2018
31b777d
bugfix: missing cases for EPA criteria in ArchiveUtils
jgaleotti Nov 3, 2018
7d92421
discarding redundant changes to BranchCoverageSuiteFitness
jgaleotti Nov 20, 2018
c4d4883
Merge remote-tracking branch 'upstream/master' into epacoverage
jgaleotti Nov 20, 2018
5f15631
Merge branch 'master' into epacoverage
jgaleotti Dec 11, 2018
37bdf3c
resolving merge conflicts
jgaleotti Feb 4, 2019
d320e59
resolving minor conflicts
jgaleotti Feb 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions client/src/main/java/org/evosuite/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,16 @@ public enum SecondaryObjective {
@Parameter(key = "synthesis_threshold", group = "Chemical Reaction Optimization", description = "Threshold to be checked to decide when to trigger synthesis")
public static int SYNTHESIS_THRESHOLD = 10;

//----------------------------------------------------------------
// EPA Coverage

@Parameter(key = "epa_xml_path", group = "EPA", description = "Indicates the path to the EPA XML File")
public static String EPA_XML_PATH = null;

@Parameter(key = "inferred_epa_xml_path", group = "EPA", description = "This option can be enabled only and only if the EPAMINING criterion is enabled")
public static String INFERRED_EPA_XML_PATH = null;


//----------------------------------------------------------------
// Continuous Test Generation

Expand Down Expand Up @@ -901,6 +911,9 @@ public enum OutputFormat {
@Parameter(key = "junit_check", group = "Output", description = "Compile and run resulting JUnit test suite (if any was created)")
public static boolean JUNIT_CHECK = true;

@Parameter(key = "junit_allow_restricted_libraries", group = "Output", description = "Allow restricted libraries (rt.jar) when compiling JUnit test suite")
public static boolean JUNIT_ALLOW_RESTRICTED_LIBRARIES = false;

@Parameter(key = "junit_check_on_separate_process", group = "Output", description = "Compile and run resulting JUnit test suite on a separate process")
@Deprecated
//this gives quite a few issues. and hopefully the problems it was aimed to fix are no longer
Expand Down Expand Up @@ -1412,13 +1425,13 @@ public enum Criterion {
EXCEPTION, DEFUSE, ALLDEFS, BRANCH, CBRANCH, STRONGMUTATION, WEAKMUTATION,
MUTATION, STATEMENT, RHO, AMBIGUITY, IBRANCH, READABILITY,
ONLYBRANCH, ONLYMUTATION, METHODTRACE, METHOD, METHODNOEXCEPTION, LINE, ONLYLINE, OUTPUT, INPUT,
REGRESSION, REGRESSIONTESTS, TRYCATCH
REGRESSION, REGRESSIONTESTS, TRYCATCH, EPATRANSITION, EPAERROR, EPAEXCEPTION, EPAMINING, EPAADJACENTEDGES
}

@Parameter(key = "criterion", group = "Runtime", description = "Coverage criterion. Can define more than one criterion by using a ':' separated list")
public static Criterion[] CRITERION = new Criterion[] {
//these are basic criteria that should be always on by default
Criterion.LINE, Criterion.BRANCH, Criterion.EXCEPTION, Criterion.WEAKMUTATION, Criterion.OUTPUT, Criterion.METHOD, Criterion.METHODNOEXCEPTION, Criterion.CBRANCH };
Criterion.LINE, Criterion.BRANCH, Criterion.EXCEPTION, Criterion.WEAKMUTATION, Criterion.OUTPUT, Criterion.METHOD, Criterion.METHODNOEXCEPTION, Criterion.CBRANCH };


/** Cache target class */
Expand Down
10 changes: 10 additions & 0 deletions client/src/main/java/org/evosuite/TestGenerationContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
package org.evosuite;

import org.evosuite.Properties.Criterion;
import java.io.File;
import java.util.Arrays;
import java.util.List;
Expand All @@ -32,6 +33,7 @@
import org.evosuite.contracts.FailingTestSet;
import org.evosuite.coverage.branch.BranchPool;
import org.evosuite.coverage.dataflow.DefUsePool;
import org.evosuite.coverage.epa.EPAMonitor;
import org.evosuite.coverage.mutation.MutationPool;
import org.evosuite.coverage.mutation.MutationTimeoutStoppingCondition;
import org.evosuite.ga.archive.Archive;
Expand Down Expand Up @@ -249,6 +251,14 @@ public void resetContext() {

DSEStats.clear();

if (ArrayUtil.contains(Properties.CRITERION, Properties.Criterion.EPATRANSITION)
|| ArrayUtil.contains(Properties.CRITERION, Criterion.EPAERROR)
|| ArrayUtil.contains(Properties.CRITERION, Criterion.EPAEXCEPTION)
|| ArrayUtil.contains(Properties.CRITERION, Criterion.EPAMINING)
|| ArrayUtil.contains(Properties.CRITERION, Criterion.EPAADJACENTEDGES)) {
EPAMonitor.reset();
}

// keep the list of initialized classes (clear them when needed in
// the system test cases)
final List<String> initializedClasses = ClassReInitializer.getInstance().getInitializedClasses();
Expand Down
86 changes: 76 additions & 10 deletions client/src/main/java/org/evosuite/TestSuiteGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
import org.evosuite.coverage.FitnessFunctions;
import org.evosuite.coverage.TestFitnessFactory;
import org.evosuite.coverage.dataflow.DefUseCoverageSuiteFitness;
import org.evosuite.coverage.epa.EPA;
import org.evosuite.coverage.epa.EPAFactory;
import org.evosuite.coverage.epa.EPATrace;
import org.evosuite.coverage.epa.EPAXMLPrinter;
import org.evosuite.coverage.epa.MalformedEPATraceException;
import org.evosuite.ga.metaheuristics.GeneticAlgorithm;
import org.evosuite.ga.stoppingconditions.StoppingCondition;
import org.evosuite.junit.JUnitAnalyzer;
Expand Down Expand Up @@ -69,16 +74,21 @@
import org.evosuite.testcase.variable.VariableReference;
import org.evosuite.testsuite.*;
import org.evosuite.utils.ArrayUtil;
import org.evosuite.utils.FileIOUtils;
import org.evosuite.utils.LoggingUtils;
import org.evosuite.utils.generic.GenericMethod;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.text.NumberFormat;
import java.util.*;

import javax.xml.parsers.ParserConfigurationException;

/**
* Main entry point. Does all the static analysis, invokes a test generation
* strategy, and then applies postprocessing.
Expand Down Expand Up @@ -128,6 +138,7 @@ public TestGenerationResult generateTestSuite() {
ExceptionMapGenerator.initializeExceptionMap(Properties.TARGET_CLASS);

TestCaseExecutor.initExecutor();

try {
initializeTargetClass();
} catch (Throwable e) {
Expand Down Expand Up @@ -262,8 +273,8 @@ public TestGenerationResult generateTestSuite() {
}
TestCaseExecutor.pullDown();
/*
* TODO: when we will have several processes running in parallel, we ll
* need to handle the gathering of the statistics.
* TODO: when we will have several processes running in parallel, we ll need to
* handle the gathering of the statistics.
*/
ClientServices.getInstance().getClientNode().changeState(ClientState.WRITING_STATISTICS);

Expand Down Expand Up @@ -379,7 +390,7 @@ private static DefaultTestCase buildLoadTargetClassTestCase(String className) th
/**
* Apply any readability optimizations and other techniques that should use
* or modify the generated tests
*
*
* @param testSuite
*/
protected void postProcessTests(TestSuiteChromosome testSuite) {
Expand Down Expand Up @@ -435,6 +446,7 @@ protected void postProcessTests(TestSuiteChromosome testSuite) {
if (!TimeController.getInstance().hasTimeToExecuteATestCase()) {
LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier()
+ "Skipping minimization because not enough time is left");

ClientServices.track(RuntimeVariable.Result_Size, testSuite.size());
ClientServices.track(RuntimeVariable.Minimized_Size, testSuite.size());
ClientServices.track(RuntimeVariable.Result_Length, testSuite.totalLengthOfTestCases());
Expand Down Expand Up @@ -462,6 +474,7 @@ protected void postProcessTests(TestSuiteChromosome testSuite) {
+ "Skipping minimization because not enough time is left");
}


ClientServices.track(RuntimeVariable.Result_Size, testSuite.size());
ClientServices.track(RuntimeVariable.Minimized_Size, testSuite.size());
ClientServices.track(RuntimeVariable.Result_Length, testSuite.totalLengthOfTestCases());
Expand All @@ -488,6 +501,7 @@ protected void postProcessTests(TestSuiteChromosome testSuite) {
if (!Properties.ANALYSIS_CRITERIA.isEmpty()) {
// SearchStatistics.getInstance().addCoverage(Properties.CRITERION.toString(),
// coverage);

CoverageCriteriaAnalyzer.analyzeCriteria(testSuite, Properties.ANALYSIS_CRITERIA);
// FIXME: can we send all bestSuites?
}
Expand Down Expand Up @@ -538,6 +552,7 @@ protected void postProcessTests(TestSuiteChromosome testSuite) {
LoggingUtils.getEvoLogger().info("* " + ClientProcess.getPrettyPrintIdentifier()
+ "Skipping assertion generation because not enough time is left");
} else {

TestSuiteGeneratorHelper.addAssertions(testSuite);
}
StatisticsSender.sendIndividualToMaster(testSuite); // FIXME: can we
Expand All @@ -563,6 +578,32 @@ else if (Properties.JUNIT_TESTS && Properties.JUNIT_CHECK) {
if(Properties.isRegression() && Properties.KEEP_REGRESSION_ARCHIVE){
RegressionSuiteSerializer.storeRegressionArchive();
}

if (ArrayUtil.contains(Properties.CRITERION, Criterion.EPAMINING)) {

if (Properties.INFERRED_EPA_XML_PATH != null) {
Set<EPATrace> traces = new HashSet<EPATrace>();
for (TestChromosome test : testSuite.getTestChromosomes()) {
// delete all statements leading to security exceptions
ExecutionResult result = test.getLastExecutionResult();
if (result == null) {
result = TestCaseExecutor.runTest(test.getTestCase());
}
Set<EPATrace> resultTraces = result.getTrace().getEPATraces();
traces.addAll(resultTraces);
}
try {
EPA inferredAutomata = EPAFactory.buildEPA(traces);
EPAXMLPrinter xmlPrinter = new EPAXMLPrinter();
String xmlFilename = Properties.INFERRED_EPA_XML_PATH;
String epa_xml_str = xmlPrinter.toXML(inferredAutomata);
FileIOUtils.writeFile(epa_xml_str, xmlFilename);

} catch (MalformedEPATraceException e) {
throw new EvosuiteError(e);
}
}
}
}

/**
Expand Down Expand Up @@ -662,6 +703,11 @@ private static int checkAllTestsIfTime(List<TestCase> testCases, long delta) {
return 0;
}

private int getBytecodeCount(RuntimeVariable v, Map<RuntimeVariable, Set<Integer>> m) {
Set<Integer> branchSet = m.get(v);
return (branchSet == null) ? 0 : branchSet.size();
}

private TestSuiteChromosome generateTests() {
// Make sure target class is loaded at this point
TestCluster.getInstance();
Expand All @@ -687,22 +733,42 @@ private TestSuiteChromosome generateTests() {
writeObjectPool(testSuite);

/*
* PUTGeneralizer generalizer = new PUTGeneralizer(); for (TestCase test
* : tests) { generalizer.generalize(test); // ParameterizedTestCase put
* = new ParameterizedTestCase(test); }
* PUTGeneralizer generalizer = new PUTGeneralizer(); for (TestCase test :
* tests) { generalizer.generalize(test); // ParameterizedTestCase put = new
* ParameterizedTestCase(test); }
*/

return testSuite;
}

private TestGenerationStrategy getTestGenerationStrategy() {
switch (Properties.STRATEGY) {
case EVOSUITE:
return new WholeTestSuiteStrategy();
case RANDOM:
return new RandomTestStrategy();
case RANDOM_FIXED:
return new FixedNumRandomTestStrategy();
case ONEBRANCH:
return new IndividualTestStrategy();
case REGRESSION:
return new RegressionSuiteStrategy();
case ENTBUG:
return new EntBugTestStrategy();
case MOSUITE:
return new MOSuiteStrategy();
default:
throw new RuntimeException("Unsupported strategy: " + Properties.STRATEGY);
}
}

/**
* <p>
* If Properties.JUNIT_TESTS is set, this method writes the given test cases
* to the default directory Properties.TEST_DIR.
* If Properties.JUNIT_TESTS is set, this method writes the given test cases to
* the default directory Properties.TEST_DIR.
*
* <p>
* The name of the test will be equal to the SUT followed by the given
* suffix
* The name of the test will be equal to the SUT followed by the given suffix
*
* @param testSuite
* a test suite.
Expand Down
6 changes: 3 additions & 3 deletions client/src/main/java/org/evosuite/classpath/ResourceList.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,10 +504,10 @@ private void initCache() {
}
}

private void addEntry(String classPathElement) throws IllegalArgumentException{
final File file = new File(classPathElement);
private void addEntry(String origClassPathElement) throws IllegalArgumentException{
final File file = new File(origClassPathElement);

classPathElement = file.getAbsolutePath();
final String classPathElement = file.getAbsolutePath();

if(getCache().mapCPtoClasses.containsKey(classPathElement)){
return; //this classpath entry has already been analyzed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ public static RuntimeVariable getCoverageVariable(Properties.Criterion criterion
return RuntimeVariable.IBranchCoverage;
case REGRESSION:
return RuntimeVariable.BranchCoverage;
case EPATRANSITION:
return RuntimeVariable.EpaTransitionCoverage;
case EPAADJACENTEDGES:
return RuntimeVariable.EpaAdjacentEdgesCoverage;
case EPAERROR:
return RuntimeVariable.EpaErrorCoverage;
case EPAEXCEPTION:
return RuntimeVariable.EpaExceptionCoverage;
case EPAMINING:
return RuntimeVariable.EpaMiningCoverage;
case TRYCATCH:
return RuntimeVariable.TryCatchCoverage;
default:
Expand Down Expand Up @@ -244,8 +254,9 @@ private static void analyzeCoverage(TestSuiteChromosome testSuite, Properties.Cr
} else {
logger.debug("Goal {} is not covered", goal);
buffer.append("0");
if (Properties.PRINT_MISSED_GOALS)
if (Properties.PRINT_MISSED_GOALS) {
LoggingUtils.getEvoLogger().info(" - Missed goal {}", goal.toString());
}
}
}

Expand Down Expand Up @@ -341,6 +352,16 @@ public static RuntimeVariable getBitStringVariable(Properties.Criterion criterio
case REGRESSIONTESTS:
case TRYCATCH:
return null;
case EPATRANSITION:
return RuntimeVariable.EpaTransitionCoverage;
case EPAADJACENTEDGES:
return RuntimeVariable.EpaAdjacentEdgesCoverage;
case EPAERROR:
return RuntimeVariable.EpaErrorCoverage;
case EPAEXCEPTION:
return RuntimeVariable.EpaExceptionCoverage;
case EPAMINING:
return RuntimeVariable.EpaMiningCoverage;
default:
logger.debug("Criterion not supported: " + criterion);
return null;
Expand Down
38 changes: 38 additions & 0 deletions client/src/main/java/org/evosuite/coverage/FitnessFunctions.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
import org.evosuite.coverage.dataflow.AllDefsCoverageTestFitness;
import org.evosuite.coverage.dataflow.DefUseCoverageFactory;
import org.evosuite.coverage.dataflow.DefUseCoverageSuiteFitness;

import org.evosuite.coverage.epa.EPAAdjacentEdgesCoverageFactory;
import org.evosuite.coverage.epa.EPAAdjacentEdgesCoverageSuiteFitness;
import org.evosuite.coverage.epa.EPAErrorCoverageFactory;
import org.evosuite.coverage.epa.EPAErrorCoverageSuiteFitness;
import org.evosuite.coverage.epa.EPAExceptionCoverageFactory;
import org.evosuite.coverage.epa.EPAExceptionCoverageSuiteFitness;
import org.evosuite.coverage.epa.EPAFactory;
import org.evosuite.coverage.epa.EPAMiningCoverageFactory;
import org.evosuite.coverage.epa.EPAMiningCoverageSuiteFitness;
import org.evosuite.coverage.epa.EPATransitionCoverageFactory;
import org.evosuite.coverage.epa.EPATransitionCoverageSuiteFitness;
import org.evosuite.coverage.dataflow.DefUseCoverageTestFitness;
import org.evosuite.coverage.exception.ExceptionCoverageFactory;
import org.evosuite.coverage.exception.ExceptionCoverageSuiteFitness;
Expand Down Expand Up @@ -83,9 +95,14 @@
import org.evosuite.coverage.statement.StatementCoverageTestFitness;
import org.evosuite.regression.RegressionSuiteFitness;
import org.evosuite.testcase.TestFitnessFunction;
import org.evosuite.testcase.execution.EvosuiteError;
import org.evosuite.testsuite.TestSuiteFitnessFunction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;

import java.util.Arrays;

Expand Down Expand Up @@ -155,6 +172,17 @@ public static TestSuiteFitnessFunction getFitnessFunction(Criterion criterion) {
return new OutputCoverageSuiteFitness();
case INPUT:
return new InputCoverageSuiteFitness();
case EPATRANSITION:
return new EPATransitionCoverageSuiteFitness(Properties.EPA_XML_PATH);
case EPAERROR:
return new EPAErrorCoverageSuiteFitness(Properties.EPA_XML_PATH);
case EPAEXCEPTION:
return new EPAExceptionCoverageSuiteFitness(Properties.EPA_XML_PATH);
case EPAMINING:
return new EPAMiningCoverageSuiteFitness();
case EPAADJACENTEDGES:
return new EPAAdjacentEdgesCoverageSuiteFitness(Properties.EPA_XML_PATH);

case TRYCATCH:
return new TryCatchCoverageSuiteFitness();
default:
Expand Down Expand Up @@ -216,6 +244,16 @@ public static TestFitnessFactory<? extends TestFitnessFunction> getFitnessFactor
return new OutputCoverageFactory();
case INPUT:
return new InputCoverageFactory();
case EPATRANSITION:
return new EPATransitionCoverageFactory(Properties.TARGET_CLASS, EPAFactory.buildEPAOrError(Properties.EPA_XML_PATH));
case EPAERROR:
return new EPAErrorCoverageFactory(Properties.TARGET_CLASS, EPAFactory.buildEPAOrError(Properties.EPA_XML_PATH));
case EPAEXCEPTION:
return new EPAExceptionCoverageFactory(Properties.TARGET_CLASS, EPAFactory.buildEPAOrError(Properties.EPA_XML_PATH));
case EPAMINING:
return new EPAMiningCoverageFactory();
case EPAADJACENTEDGES:
return new EPAAdjacentEdgesCoverageFactory(EPAFactory.buildEPAOrError(Properties.EPA_XML_PATH));
case TRYCATCH:
return new TryCatchCoverageFactory();
default:
Expand Down
Loading