예제 #1
0
  private void computeCoverages(
      String packageFilter,
      List<Map.Entry<String, ClassCoverage>> clsEntries,
      Coverage cls,
      Coverage mth,
      Coverage branch,
      Coverage block,
      Coverage line,
      Coverage insn) {
    for (Map.Entry<String, ClassCoverage> e : clsEntries) {
      if (e.getKey().startsWith(packageFilter)) {
        ClassCoverage cc = e.getValue();

        if (cc.isInterface()) {
          continue; // no code
        }

        cls.total++;

        if (cc.covered) {
          cls.covered++;
        }

        insn.add(cc.getCoveredInsn());
        line.add(cc.getCoveredLines());
        block.add(cc.getCoveredBasicBlocks());
        branch.add(cc.getCoveredBranches());
        mth.add(cc.getCoveredMethods());
      }
    }
  }
예제 #2
0
    void printRequirementsCoverage() {
      HashMap<String, Integer> reqMethods = getGlobalRequirementsMethods();

      String space = "  ";
      Coverage bbAll = new Coverage(0, 0);
      Coverage insnAll = new Coverage(0, 0);
      Coverage branchAll = new Coverage(0, 0);
      Coverage mthAll = new Coverage(0, 0);
      Coverage reqAll = new Coverage(0, 0);

      reqAll.total = reqMethods.size();
      mthAll.total = computeTotalRequirementsMethods(reqMethods);

      pw.println();
      pw.println();
      pw.println(
          "--------------------------------- requirements coverage -----------------------------------");
      pw.println(
          "bytecode            basic-block         branch              methods             requirement");
      pw.println(
          "-------------------------------------------------------------------------------------------");

      for (String id : Misc.getSortedKeyStrings(reqMethods)) {

        Coverage bbCoverage = new Coverage(0, 0);
        Coverage insnCoverage = new Coverage(0, 0);
        Coverage branchCoverage = new Coverage(0, 0);
        Coverage reqMth = new Coverage(reqMethods.get(id), 0);

        if (requirements != null && requirements.containsKey(id)) {
          reqAll.covered++;
          for (MethodCoverage mc : requirements.get(id)) {
            insnCoverage.add(mc.getCoveredInsn());
            bbCoverage.add(mc.getCoveredBasicBlocks());
            branchCoverage.add(mc.getCoveredBranches());

            mthAll.covered++;
            reqMth.covered++;
          }

          printCoverage(insnCoverage);
          pw.print(space);
          printCoverage(bbCoverage);
          pw.print(space);
          printCoverage(branchCoverage);
          pw.print(space);
          printCoverage(reqMth);
          pw.print("\"" + id + "\"");

          pw.println();

          if (showMethods) {
            for (MethodCoverage mc : requirements.get(id)) {

              pw.print(space);
              printCoverage(mc.getCoveredInsn());
              pw.print(space);
              printCoverage(mc.getCoveredBasicBlocks());
              pw.print(space);
              printCoverage(mc.getCoveredBranches());
              pw.print(space);

              pw.print(mc.getMethodInfo().getFullName());
              pw.println();
            }
          }
        } else { // requirement not covered
          pw.print(" -                   -                   -                  ");

          printCoverage(reqMth);
          pw.print("\"" + id + "\"");
          pw.println();
        }

        insnAll.add(insnCoverage);
        bbAll.add(bbCoverage);
        branchAll.add(branchCoverage);
      }

      pw.println();
      pw.println(
          "------------------------------------------------------------------------------------------");

      printCoverage(insnAll);
      pw.print(space);
      printCoverage(bbAll);
      pw.print(space);
      printCoverage(branchAll);
      pw.print(space);
      printCoverage(mthAll);
      pw.print(space);
      printCoverage(reqAll);
      pw.print(" total");

      pw.println();
    }
예제 #3
0
    void printRequirementsCoverage() {
      HashMap<String, Integer> reqMethods = getGlobalRequirementsMethods();

      Coverage bbAll = new Coverage(0, 0);
      Coverage insnAll = new Coverage(0, 0);
      Coverage branchAll = new Coverage(0, 0);
      Coverage mthAll = new Coverage(0, 0);
      Coverage reqAll = new Coverage(0, 0);

      reqAll.total = reqMethods.size();
      mthAll.total = computeTotalRequirementsMethods(reqMethods);

      pw.println("      <p><b>Requirements Coverage</b></p>");
      pw.println("      <table>");
      pw.println(
          "         <tr><th colspan=\"4\">Instructions</th><th colspan=\"4\">Basic Block</th><th colspan=\"4\">Branch</th><th colspan=\"4\">Methods</th><th colspan=\"4\">Requirement</th></tr>");

      for (String id : Misc.getSortedKeyStrings(reqMethods)) {

        Coverage bbCoverage = new Coverage(0, 0);
        Coverage insnCoverage = new Coverage(0, 0);
        Coverage branchCoverage = new Coverage(0, 0);
        Coverage reqMth = new Coverage(reqMethods.get(id), 0);

        if (requirements != null && requirements.containsKey(id)) {
          reqAll.covered++;
          for (MethodCoverage mc : requirements.get(id)) {
            insnCoverage.add(mc.getCoveredInsn());
            bbCoverage.add(mc.getCoveredBasicBlocks());
            branchCoverage.add(mc.getCoveredBranches());

            mthAll.covered++;
            reqMth.covered++;
          }

          pw.print("         <tr>");

          printCoverage(insnCoverage);
          printCoverage(bbCoverage);
          printCoverage(branchCoverage);
          printCoverage(reqMth);
          pw.print("\"" + id + "\"");

          pw.print("</tr>");

          pw.println();

          if (showMethods) {
            for (MethodCoverage mc : requirements.get(id)) {

              pw.print("         <tr>");

              printCoverage(mc.getCoveredInsn());
              printCoverage(mc.getCoveredBasicBlocks());
              printCoverage(mc.getCoveredBranches());

              pw.print("<td align=\"left\" colspan=\"4\" style=\"padding-right: 10px;\">");

              pw.print(mc.getMethodInfo().getFullName());

              pw.print("</tr>");

              pw.println();
            }
          }
        } else { // requirement not covered
          pw.print(
              "         <tr><td colspan=\"4\"></td><td colspan=\"4\"></td><td colspan=\"4\"></td>");

          printCoverage(reqMth);
          pw.print("\"" + id + "\"");

          pw.print("</tr>");

          pw.println();
        }

        insnAll.add(insnCoverage);
        bbAll.add(bbCoverage);
        branchAll.add(branchCoverage);
      }

      pw.print("         <tr>");

      printCoverage(insnAll);
      printCoverage(bbAll);
      printCoverage(branchAll);
      printCoverage(mthAll);
      printCoverage(reqAll);
      pw.print(" total");

      pw.println("</tr>");
      pw.println("      </table>");
    }