@Test
  public void testFieldWithErrorBranches() {

    EvoSuite evosuite = new EvoSuite();

    String targetClass = Fieldaccess.class.getCanonicalName();

    Properties.TARGET_CLASS = targetClass;
    Properties.ERROR_BRANCHES = true;
    Properties.CRITERION =
        new Properties.Criterion[] {Properties.Criterion.BRANCH, Properties.Criterion.TRYCATCH};

    String[] command = new String[] {"-generateSuite", "-class", targetClass};

    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();

    Assert.assertEquals(
        2, TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size());
    Assert.assertEquals(
        2, TestGenerationStrategy.getFitnessFactories().get(1).getCoverageGoals().size());

    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
  }
  @Test
  public void testWeakMutationSimpleExampleWithoutArchive() {
    EvoSuite evosuite = new EvoSuite();
    boolean archive = Properties.TEST_ARCHIVE;
    Properties.TEST_ARCHIVE = false;
    Properties.CRITERION = new Properties.Criterion[] {Criterion.WEAKMUTATION};

    String targetClass = SimpleMutationExample1.class.getCanonicalName();

    String[] command = new String[] {"-generateSuite", "-class", targetClass};
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    Properties.TEST_ARCHIVE = archive;

    System.out.println("CoveredGoals:\n" + best.getCoveredGoals());
    System.out.println("EvolvedTestSuite:\n" + best);
    int goals =
        TestGenerationStrategy.getFitnessFactories()
            .get(0)
            .getCoverageGoals()
            .size(); // assuming single fitness function
    Assert.assertEquals(12, goals);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
  }
  public void testMethodFitnessSimpleExample() {
    EvoSuite evosuite = new EvoSuite();

    String targetClass = SingleMethod.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;

    String[] command = new String[] {"-generateSuite", "-class", targetClass};
    Object result = evosuite.parseCommandLine(command);
    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();

    System.out.println("EvolvedTestSuite:\n" + best);
    int goals =
        TestGenerationStrategy.getFitnessFactories()
            .get(0)
            .getCoverageGoals()
            .size(); // assuming single fitness function
    Assert.assertEquals(2, goals);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
  }
  @Test
  public void systemTestCanUseHashCode() {

    EvoSuite evosuite = new EvoSuite();

    String targetClass = EqualsHashCode.class.getCanonicalName();
    Properties.TARGET_CLASS = targetClass;

    Properties.CRITERION = new Properties.Criterion[] {Properties.Criterion.METHOD};
    String[] command = new String[] {"-generateSuite", "-class", targetClass};

    Object result = evosuite.parseCommandLine(command);

    GeneticAlgorithm<?> ga = getGAFromResult(result);
    TestSuiteChromosome best = (TestSuiteChromosome) ga.getBestIndividual();
    int goals = TestGenerationStrategy.getFitnessFactories().get(0).getCoverageGoals().size();
    Assert.assertEquals(4, goals);

    System.out.println("EvolvedTestSuite:\n" + best);
    Assert.assertEquals("Non-optimal coverage: ", 1d, best.getCoverage(), 0.001);
  }