Add the SimpleTestReportFormatter.
This commit is contained in:
+57
@@ -0,0 +1,57 @@
|
||||
package space.kklochko.simple_jbdd.tests.reports.fmt;
|
||||
|
||||
import space.kklochko.simple_jbdd.tests.Test;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class SimpleTestReportFormatter {
|
||||
private ArrayList<AbstractMap.SimpleEntry<String, String>> testMetaData;
|
||||
private boolean isPassed;
|
||||
final private String passedIcon = "✓";
|
||||
final private String failedIcon = "⨯";
|
||||
|
||||
public SimpleTestReportFormatter(ArrayList<AbstractMap.SimpleEntry<String, String>> testMetaData, boolean isPassed) {
|
||||
setTestMetaData(testMetaData);
|
||||
setPassed(isPassed);
|
||||
}
|
||||
|
||||
public String format() {
|
||||
String status = (isPassed) ? getPassedIcon() : getFailedIcon();
|
||||
String title = getTestMetaData().get(0).getValue();
|
||||
|
||||
String result = String.format("%s %s\n", status, title);
|
||||
|
||||
for(int i=1; i<getTestMetaData().size(); ++i) {
|
||||
AbstractMap.SimpleEntry<String, String> pair = getTestMetaData().get(i);
|
||||
result += String.format("\t%s %s\n", pair.getKey(), pair.getValue());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<AbstractMap.SimpleEntry<String, String>> getTestMetaData() {
|
||||
return testMetaData;
|
||||
}
|
||||
|
||||
public void setTestMetaData(ArrayList<AbstractMap.SimpleEntry<String, String>> testMetaData) {
|
||||
this.testMetaData = testMetaData;
|
||||
}
|
||||
|
||||
public boolean isPassed() {
|
||||
return isPassed;
|
||||
}
|
||||
|
||||
public void setPassed(boolean passed) {
|
||||
isPassed = passed;
|
||||
}
|
||||
|
||||
public String getPassedIcon() {
|
||||
return passedIcon;
|
||||
}
|
||||
|
||||
public String getFailedIcon() {
|
||||
return failedIcon;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user