@Override
  public void close() throws IOException {
    if (suiteTime == null || suiteTime.isStopped()) return;
    suiteTime.stop();
    totalTimeMeasurement.stop();

    suiteExecutionReport.setTotalRunTimeInMillis(totalTimeMeasurement);

    if (testHistoryFormatter != null) {
      testHistoryFormatter.close();
    }

    if (PageType.fromWikiPage(getPage()) == PageType.SUITE) {
      Writer writer =
          writerFactory.getWriter(context, getPage(), getPageCounts(), suiteTime.startedAt());
      try {
        VelocityContext velocityContext = new VelocityContext();
        velocityContext.put("suiteExecutionReport", getSuiteExecutionReport());
        VelocityEngine velocityEngine = context.pageFactory.getVelocityEngine();
        Template template = velocityEngine.getTemplate("suiteHistoryXML.vm");
        template.merge(velocityContext, writer);
      } finally {
        writer.close();
      }
    }
  }
  public static PageType fromString(String typeDescriptor) {
    for (PageType type : PageType.values()) {
      if (type.description.equalsIgnoreCase(typeDescriptor)) {
        return type;
      }
    }

    throw new IllegalArgumentException("unknown page type descriptor: " + typeDescriptor);
  }
 public static PageType getPageTypeForPageName(String pageName) {
   for (PageType type : values()) {
     if (type.validForPageName(pageName)) return type;
   }
   return STATIC;
 }
 private boolean isMultipleTestsRun() {
   return PageType.fromWikiPage(page) == PageType.SUITE;
 }