-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportHtml.java
More file actions
42 lines (38 loc) · 2.29 KB
/
ReportHtml.java
File metadata and controls
42 lines (38 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
public class ReportHtml implements TestReporter{
File htmlFile;
public ReportHtml(String filename){
htmlFile = new File(filename);
}
public void generateHtml(List<TestResult> passed, List<TestResult> failed, List<TestResult> exception) throws IOException{
BufferedWriter bw = new BufferedWriter(new FileWriter(htmlFile));
bw.write("<!DOCTYPE html>\n<head>\n<title>Tae's Testing Frame with Results and Description</title></head><body><p>Tests results with the descriptions</p></body>");
bw.write("<body><p> </p></body>\n");
bw.write("<body><p> </p></body>\n");
bw.write("<body><p>PASSED TESTS</p></body>\n");
bw.write("<body><p>Result            Description</p></body>\n");
for (int i =0; i < passed.size(); i++){
bw.write("<body><p>" + passed.get(i).type + " " + " " + " " + " " + " " + " " + " " + " " + passed.get(i).description + "</p></body>" + "\n");
}
bw.write("<body><p> </p></body>\n");
bw.write("<body><p> </p></body>\n");
bw.write("<body><p>FAILED TESTS</p></body>\n");
bw.write("<body><p>Result            Description</p></body>\n");
for (int i =0; i < failed.size(); i++){
bw.write("<body><p>" + failed.get(i).type + " " + " " + " " + " " + " " + " " + " " + " " + failed.get(i).description + "</p></body>" + "\n");
}
bw.write("<body><p> </p></body>\n");
bw.write("<body><p> </p></body>\n");
bw.write("<body><p>EXCEPTION TESTS</p></body>\n");
bw.write("<body><p>Result                     Description</p></body>\n");
for (int i =0; i < exception.size(); i++){
bw.write("<body><p>" + exception.get(i).type + " " + " " + " " + " " + " " + " " + " " + " " + exception.get(i).description + "</p></body>" + "\n");
}
bw.write("</html>");
bw.close();
}
}