コード例 #1
0
ファイル: Timeline.java プロジェクト: sqrlab/PriorityTestVis
  private static boolean greedySwitch(
      ArrayList<TestResult> testSuite, ArrayList<TestResult> unused) {
    TestResult max = unused.get(0);
    TestResult min = testSuite.get(0);

    for (TestResult i : testSuite) {
      if (i.getUniqueMutants().size() < min.getUniqueMutants().size()) {
        min = i;
      }
    }

    for (TestResult i : unused) {
      if (i.getUniqueMutants().size() > max.getUniqueMutants().size()) {
        max = i;
      }
    }

    if (min.getUniqueMutants().equals(0) && !(max.getUniqueMutants().equals(0))) {
      int testSuiteLoc = testSuite.indexOf(min);
      testSuite.remove(testSuiteLoc);
      testSuite.add(testSuiteLoc, max);

      int unusedLoc = unused.indexOf(max);
      unused.remove(unusedLoc);
      unused.add(unusedLoc, min);

      return true;
    }

    return false;
  }
コード例 #2
0
ファイル: Timeline.java プロジェクト: sqrlab/PriorityTestVis
  // Fitness function that gives higher score based on best time while maintining minimum mutant
  // score
  // Higher scores are better
  private static double fitnessOnTime(ArrayList<TestResult> solution, int targetScore) {
    double time = 0.0;
    int score = 0;

    for (TestResult i : solution) {
      score += i.getUniqueMutants().size();
      time += i.getTime();
    }

    if (score < targetScore) {
      return Double.MIN_VALUE;
    } else {
      return 1 / time;
    }
  }
コード例 #3
0
ファイル: Timeline.java プロジェクト: sqrlab/PriorityTestVis
  // Fitness function that gives higher score based on better mutantscore without going over target
  // time
  // Higher scores are better
  private static int fitnessOnScore(ArrayList<TestResult> solution, double targetTime) {
    double time = 0.0;
    int score = 0;

    for (TestResult i : solution) {
      score += i.getUniqueMutants().size();
      time += i.getTime();
    }

    if (time > targetTime) {
      return 0;
    } else {
      return score;
    }
  }