示例#1
0
文件: proc.java 项目: qupi/googleFW
 /**
  * Log a step into test case result.
  *
  * @param tcName
  * @param result
  * @param msg
  */
 public void logStep(String tcName, String result, String msg) {
   if ("".equals(tcName)) {
     tcName = oi.logRunningTC;
     if (!"".equals(result.trim())) {
       if ("false".equals(StringUtils.lowerCase(result.trim()))) {
         oi.logList.add(
             tcName
                 + ","
                 + result.trim()
                 + ",At step "
                 + init.currentStep
                 + " of "
                 + init.sumStep
                 + ","
                 + msg.trim());
       } else {
         oi.logList.add(tcName + "," + result.trim() + "," + msg.trim());
       }
     }
   } else {
     if (StringUtils.left(tcName, 4).equals("test")) {
       tcName = StringUtils.mid(tcName, 4, tcName.length());
     }
     oi.logRunningTC = tcName;
     if ("".equals(result.trim())) {
       oi.logList.add(tcName + "," + init.logTcStart);
     } else {
       oi.logList.add(tcName + "," + result.trim());
     }
   }
 }
示例#2
0
文件: proc.java 项目: qupi/googleFW
  /**
   * Log all test case results to file. Depend on 'log' configuration details will be log or not.
   *
   * @throws IOException
   */
  public void logToFile() throws IOException {
    /*
    // Generate file name
    String DATE_FORMAT_NOW = "yyyyMMddHHmmssmm";
    Calendar cal = Calendar.getInstance();
    SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);

    //String fileName = "report-" + sdf.format(cal.getTime())+ "-" + ran.nextInt(100);
    //System.out.println("File Name is : " + oi.reportFilePath + fileName);
     *
     */

    String fileName = init.defaultReportFileName;

    // Create new file
    File reportFile = new File("C:\\" + fileName + ".csv");
    if (reportFile.exists() == false) {
      reportFile.createNewFile();
    }

    // Write log to reportFile
    FileWriter outFile = new FileWriter(reportFile, true);
    PrintWriter out = new PrintWriter(outFile, true);

    Iterator<?> stepper = oi.logList.iterator();

    while (stepper.hasNext()) {
      out.println(stepper.next());
    }

    out.close();

    System.out.println("File Name is : " + reportFile);

    // Clear logList
    oi.logList = new ArrayList<String>();
  }