-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestRunner.java
More file actions
38 lines (31 loc) · 983 Bytes
/
Copy pathTestRunner.java
File metadata and controls
38 lines (31 loc) · 983 Bytes
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
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TestRunner {
public static void main() {
Result result = JUnitCore.runClasses(Teste.class);
int count;
String msg;
long time = result.getRunTime();
System.out.println("\n\nRESULTADO DA EXECUÇÃO DOS TESTES");
System.out.println("Tempo: " + time + " ms");
if (result.wasSuccessful()) {
count = result.getRunCount();
if (count == 1)
msg = count + " teste executado com sucesso";
else
msg = count + " testes executados com sucesso";
}
else {
count = result.getFailureCount();
if (count == 1)
msg = count + " teste falhou";
else
msg = count + " testes falharam";
}
System.out.println(msg);
for (Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
}
}