All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.hsac.fitnesse.junit.reportmerge.writer.CsvOverviewFileWriter Maven / Gradle / Ivy

There is a newer version: 5.3.17
Show newest version
package nl.hsac.fitnesse.junit.reportmerge.writer;

import nl.hsac.fitnesse.junit.reportmerge.TestReportHtml;

import java.io.File;
import java.util.List;

public class CsvOverviewFileWriter extends OverviewFileWriter {
    private String fieldSeparator = "\t";

    public CsvOverviewFileWriter(File parentDir) {
        super(parentDir, "test-results.csv");
    }

    @Override
    protected void writeContent(List reports) {
        writeHeader();
        writeLineEnd();
        for (TestReportHtml report : reports) {
            writeRow(report);
            writeLineEnd();
        }
    }

    protected void writeHeader() {
        pw.write("Run name");
        appendField("Test name");
        appendField("Is overview");
        appendField("Status");
        appendField("Runtime (in milliseconds)");
        appendField("Relative Path");
    }

    protected void writeRow(TestReportHtml report) {
        pw.write(report.getRunName());
        appendField(report.getTestName());
        appendField(Boolean.toString(report.isOverviewPage()));
        appendField(report.getStatus());
        appendField(report.getTime() < 0 ? "unknown" : Long.toString(report.getTime()));
        appendField(report.getRelativePath());
    }

    protected void appendField(String value) {
        pw.write(getFieldSeparator());
        pw.write(value);
    }

    protected void writeLineEnd() {
        pw.write("\n");
    }

    public String getFieldSeparator() {
        return fieldSeparator;
    }

    public void setFieldSeparator(String fieldSeparator) {
        this.fieldSeparator = fieldSeparator;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy