Search in sources :

Example 1 with Strategy

use of org.evosuite.Properties.Strategy in project evosuite by EvoSuite.

the class TestGeneration method getChosenStrategy.

private static Strategy getChosenStrategy(List<String> javaOpts, CommandLine line) {
    Strategy strategy = null;
    if (javaOpts.contains("-Dstrategy=" + Strategy.ENTBUG.name()) && line.hasOption("generateTests")) {
        strategy = Strategy.ENTBUG;
    // TODO: Find a better way to integrate this
    } else if (javaOpts.contains("-Dstrategy=" + Strategy.NOVELTY.name())) {
        // TODO: Find a better way to integrate this
        strategy = Strategy.NOVELTY;
    } 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("regressionSuite")) {
        strategy = Strategy.REGRESSION;
    } 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;
    }
    return strategy;
}
Also used : Strategy(org.evosuite.Properties.Strategy)

Example 2 with Strategy

use of org.evosuite.Properties.Strategy in project evosuite by EvoSuite.

the class TestGeneration method executeTestGeneration.

public static List<List<TestGenerationResult>> executeTestGeneration(Options options, List<String> javaOpts, CommandLine line) {
    Strategy strategy = getChosenStrategy(javaOpts, line);
    if (strategy == null) {
        strategy = Strategy.EVOSUITE;
    }
    List<List<TestGenerationResult>> results = new ArrayList<List<TestGenerationResult>>();
    if (line.getOptions().length == 0) {
        Help.execute(options);
        return results;
    }
    String cp = ClassPathHandler.getInstance().getTargetProjectClasspath();
    if (cp == null || cp.isEmpty()) {
        LoggingUtils.getEvoLogger().error("No classpath has been defined for the target project.\nOn the command line you can set it with the -projectCP option\n");
        Help.execute(options);
        return results;
    }
    if (line.hasOption("class")) {
        results.addAll(generateTests(strategy, line.getOptionValue("class"), javaOpts));
    } else if (line.hasOption("prefix")) {
        results.addAll(generateTestsPrefix(strategy, line.getOptionValue("prefix"), javaOpts));
    } else if (line.hasOption("target")) {
        String target = line.getOptionValue("target");
        results.addAll(generateTestsTarget(strategy, target, javaOpts));
    } else if (EvoSuite.hasLegacyTargets()) {
        results.addAll(generateTestsLegacy(strategy, javaOpts));
    } else {
        LoggingUtils.getEvoLogger().error("Please specify either target class ('-class' option), prefix ('-prefix' option), or " + "classpath entry ('-target' option)\n");
        Help.execute(options);
    }
    return results;
}
Also used : TestGenerationResult(org.evosuite.result.TestGenerationResult) Strategy(org.evosuite.Properties.Strategy) ResourceList(org.evosuite.classpath.ResourceList)

Aggregations

Strategy (org.evosuite.Properties.Strategy)2 ResourceList (org.evosuite.classpath.ResourceList)1 TestGenerationResult (org.evosuite.result.TestGenerationResult)1