Exemplo n.º 1
0
  public PhpUnitResultWriter(
      File dir,
      PhpBuildInfo build_info,
      AHost host,
      ScenarioSetSetup scenario_set_setup,
      PhpUnitSourceTestPack test_pack)
      throws FileNotFoundException, IOException {
    this.build_info = build_info;
    this.host = host;
    this.scenario_set_setup = scenario_set_setup;
    this.test_pack_name_and_version = test_pack.getNameAndVersionString().intern();

    this.dir = dir;
    dir.mkdirs();

    all_csv_pw = new PrintWriter(new FileWriter(new File(dir, "ALL.csv")));
    started_pw = new PrintWriter(new FileWriter(new File(dir, "STARTED.txt")));

    output_by_name = new HashMap<String, String>(800);

    // include scenario-set in file name to make it easier to view a bunch of them in Notepad++ or
    // other MDIs
    File file =
        new File(
            dir
                + "/"
                + StringUtil.max(
                    "phpunit_"
                        + test_pack.getName()
                        + "_"
                        + scenario_set_setup.getNameWithVersionInfo(),
                    40)
                + ".xml");

    // XXX write host, scenario_set and build to file (do in #writeTally or #close)
    main_serial = new KXmlSerializer();
    extra_serial = new KXmlSerializer();

    main_serial.setOutput(out = new BufferedOutputStream(new FileOutputStream(file)), "utf-8");

    // setup serializer to indent XML (pretty print) so its easy for people to read
    main_serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    extra_serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);

    status_list_map = new HashMap<EPhpUnitTestStatus, StatusListEntry>();
    for (EPhpUnitTestStatus status : EPhpUnitTestStatus.values()) {
      status_list_map.put(status, new StatusListEntry(status));
    }
  }