forked from BugorDmitriy/OpenWeatherJavaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportUtils.java
More file actions
62 lines (47 loc) · 2.15 KB
/
Copy pathReportUtils.java
File metadata and controls
62 lines (47 loc) · 2.15 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package utils;
import base.BaseTest;
import org.testng.ITestContext;
import org.testng.ITestResult;
import java.lang.reflect.Method;
public class ReportUtils {
public final static String END_LINE =
"\n______________________________________________________________________________________________________________________________";
private final static String H_LINE =
" ==========================================================================================\n";
private static String getTestStatus(ITestResult result) {
int status = result.getStatus();
switch (status) {
case 1:
return "\u001B[32m" + "PASS" + "\u001B[0m";
case 2:
return "\u001B[31m" + "FAIL" + "\u001B[0m";
default:
return "UNDEFINED";
}
}
private static String getTestRunTime(ITestResult result) {
final long time = result.getEndMillis() - result.getStartMillis();
return DateTimeUtils.getTimeInMinSecFormat(time);
}
public static String getReportHeader(ITestContext context) {
String header = "\tTest Report\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + "\n";
String currentDate = "\tDate: "
+ DateTimeUtils.getCurrentDateTime()
+ "\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + "\n";
String projectName = "\tProject: OpenWeatherJava_05" + "\n";
String baseURL = "\tBASE_URL: " + BaseTest.getBaseUrl()
+ "\t\t\t\t\t\t\t\t\t\t\t" + "\n";
return H_LINE + header + currentDate + projectName + baseURL + H_LINE;
}
public static String getClassNameTestName(Method method, ITestResult result) {
String className = result.getTestClass().toString();
String testName = method.getName();
return className.substring(22, className.length() - 1) + "/" + testName;
}
public static String getTestStatistics(Method method, ITestResult result) {
return getClassNameTestName(method, result)
+ " ---- " + getTestStatus(result)
+ "\t Run Time: " + getTestRunTime(result)
+ END_LINE;
}
}