Open saiema opened 2 years ago
Hi @saiema,
Good catch. And yes, moving Properties.STRATEGY = strategy;
to after the if
statement would make sense. I would also suggest to adapt the getChosenStrategy
to further check the -Dstrategy=
property, e.g., replacing
} else if (line.hasOption("generateTests")) {
strategy = Strategy.ONEBRANCH;
} else if (line.hasOption("generateSuite")) {
strategy = Strategy.EVOSUITE;
} else if (line.hasOption("generateRandom")) {
strategy = Strategy.RANDOM;
} else if (line.hasOption("generateNumRandom")) {
strategy = Strategy.RANDOM_FIXED;
javaOpts.add("-Dnum_random_tests="
+ line.getOptionValue("generateNumRandom"));
} else if (line.hasOption("generateMOSuite")) {
strategy = Strategy.MOSUITE;
} else if (line.hasOption("generateSuiteUsingDSE")) {
strategy = Strategy.DSE;
}
with
} else if (javaOpts.contains("-Dstrategy=" + Strategy.ONEBRANCH.name()) || line.hasOption("generateTests")) {
strategy = Strategy.ONEBRANCH;
} else if (javaOpts.contains("-Dstrategy=" + Strategy.EVOSUITE.name()) || line.hasOption("generateSuite")) {
strategy = Strategy.EVOSUITE;
} else if (javaOpts.contains("-Dstrategy=" + Strategy.RANDOM.name()) || line.hasOption("generateRandom")) {
strategy = Strategy.RANDOM;
} else if (javaOpts.contains("-Dstrategy=" + Strategy.RANDOM_FIXED.name()) || line.hasOption("generateNumRandom")) {
strategy = Strategy.RANDOM_FIXED;
javaOpts.add("-Dnum_random_tests="
+ line.getOptionValue("generateNumRandom"));
} else if (javaOpts.contains("-Dstrategy=" + Strategy.MOSUITE.name()) || line.hasOption("generateMOSuite")) {
strategy = Strategy.MOSUITE;
} else if (javaOpts.contains("-Dstrategy=" + Strategy.DSE.name()) || line.hasOption("generateSuiteUsingDSE")) {
strategy = Strategy.DSE;
}
@saiema any chance you can pull request these changes?
-- Best, Jose
Dear @jose ,
It's been a while since I last work with Evosuite, my version was heavily modified. I will try to make a pull request with those changes if I can manage some free time to do it.
Kind regards,
Simón.
Ok, thanks in advance.
@jose I need to check if my changes didn't introduce any bugs. I think that I only need to run tests that verify arguments, is there any specific set of tests that I can call?
I'm not aware of such set of tests. If there isn't any, please write a couple system tests (as part of your pull request).
https://github.com/EvoSuite/evosuite/blob/8730aedd6cbcbeac1d7f246b4f223bda395212c9/master/src/main/java/org/evosuite/executionmode/TestGeneration.java#L64
In this line,
strategy
is given a default value (MOSUITE
) because it wasnull
. ButProperties.STRATEGY
is stillnull
. One fix is moving line 61 after the if statement.This issue appears to spawn from not parsing
-Dstrategy=MOSUITE
: when given this argument, Evosuite ends up using the default strategy, which coincidentally isMOSUITE
.