コード例 #1
0
 @Override
 public String analyze(Iterable<Mutation> mutations, HtmlReport report) {
   List<String> lines = new ArrayList<String>();
   for (Mutation mutation : mutations) {
     if (mutation.isKilled()) {
       MutationTestResult result = mutation.getMutationResult();
       Set<TestMessage> detecting = new HashSet<TestMessage>();
       Collection<TestMessage> failures = result.getFailures();
       detecting.addAll(failures);
       Collection<TestMessage> errors = result.getErrors();
       detecting.addAll(errors);
       String tests = getIds(detecting);
       String line = mutation.getId() + "," + tests;
       lines.add(line);
     }
   }
   Set<Entry<String, Integer>> entrySet = testsIds.entrySet();
   lines.add("Ids");
   for (Entry<String, Integer> entry : entrySet) {
     lines.add(entry.getKey() + "," + entry.getValue());
   }
   try {
     FileUtils.writeLines(new File("detectedByTest.csv"), lines);
   } catch (IOException e) {
     e.printStackTrace();
   }
   return Joiner.on("\n").join(lines);
 }
コード例 #2
0
 /** @return The names of the classes to mutate. */
 public Collection<String> getClassNames() {
   Set<String> classNames = new HashSet<String>();
   for (Mutation m : mutations) {
     classNames.add(m.getClassName());
   }
   return classNames;
 }
コード例 #3
0
 /**
  * Checks whether a mutation is a mutation for this run (should be applied).
  *
  * @param mutation the mutation to check
  * @return true, if the given mutation is a mutation for this run.
  */
 public boolean containsMutation(Mutation mutation) {
   if (mutation != null) {
     for (Mutation m : mutations) {
       if (mutation.equalsWithoutIdAndResult(m)) {
         return true;
       }
     }
   }
   return false;
 }
コード例 #4
0
 public MutationsForRun(File idFile, boolean filter) {
   if (idFile == null || !idFile.exists()) {
     throw new RuntimeException("Given id file does not exist: " + idFile);
   }
   mutations = getMutationsForRun(idFile, filter);
   logger.info(
       "Got "
           + mutations.size()
           + " mutations from file: "
           + idFile); // + " Trace " + Util.getStackTraceString()
   List<Long> ids = new ArrayList<Long>();
   for (Mutation m : mutations) {
     logger.debug("Mutation ID: " + m.getId());
     logger.debug(m);
     ids.add(m.getId());
   }
   String join = StringUtils.join(ids.toArray(), ", ");
   logger.debug("Mutation Ids: " + join);
 }
コード例 #5
0
 /**
  * Removes the mutations that have a result from the given list of mutations.
  *
  * @param mutations the list of mutations to be filtered.
  */
 private static void filterMutationsWithResult(List<Mutation> mutations) {
   if (mutations != null) {
     // make sure that we have not got any mutations that have already an
     // result
     Session session = HibernateUtil.getSessionFactory().openSession();
     Transaction tx = session.beginTransaction();
     List<Mutation> toRemove = new ArrayList<Mutation>();
     for (Mutation m : mutations) {
       session.load(m, m.getId());
       if (m.getMutationResult() != null) {
         logger.debug("Found mutation that already has a mutation result " + m);
         toRemove.add(m);
       }
     }
     mutations.removeAll(toRemove);
     tx.commit();
     session.close();
   }
 }