-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestControllerImpl.java
More file actions
43 lines (37 loc) · 1.31 KB
/
TestControllerImpl.java
File metadata and controls
43 lines (37 loc) · 1.31 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
42
import java.io.IOException;
import java.util.ArrayList;
public class TestControllerImpl implements TestController{
MinPriorityQueue tQueue = new MinPriorityQueue();
ArrayList<TestResult> pass = new ArrayList<TestResult>();
ArrayList<TestResult> failed = new ArrayList<TestResult>();
ArrayList<TestResult> exception = new ArrayList<TestResult>();
String nameFile;
public TestControllerImpl(String filename){
nameFile = filename;
}
@Override
public void addTest(Test test, double rank) {
tQueue.enqueue(rank, test);
}
@Override
public void runTests() {
while (tQueue.items.size() >= 1){
try{
PriQueueNode currNode = (PriQueueNode)tQueue.dequeue();
TestResult tResult = ((Test)currNode.data).runTest();
if (tResult.isPassed()){
pass.add(tResult);
} else if (tResult.isFailed()){
failed.add(tResult);
}
} catch (Exception e){
exception.add(TestResult.createExceptionResult(e.getMessage()));
}
}
}
@Override
public void createReport() throws IOException {
TestReporter report = new ReportHtml(nameFile);
report.generateHtml(pass, failed, exception);
}
}