|
6 | 6 | import com.anhtester.enums.AuthorType; |
7 | 7 | import com.anhtester.enums.Browser; |
8 | 8 | import com.anhtester.enums.CategoryType; |
9 | | -import com.anhtester.helpers.CaptureHelpers; |
10 | | -import com.anhtester.helpers.FileHelpers; |
11 | | -import com.anhtester.helpers.PropertiesHelpers; |
12 | | -import com.anhtester.helpers.ScreenRecorderHelpers; |
| 9 | +import com.anhtester.helpers.*; |
13 | 10 | import com.anhtester.keywords.WebUI; |
14 | 11 | import com.anhtester.reports.AllureManager; |
15 | 12 | import com.anhtester.reports.ExtentReportManager; |
|
24 | 21 | import org.testng.*; |
25 | 22 |
|
26 | 23 | import java.awt.*; |
| 24 | +import java.io.BufferedReader; |
27 | 25 | import java.io.IOException; |
| 26 | +import java.io.InputStreamReader; |
28 | 27 |
|
29 | 28 | import static com.anhtester.constants.FrameworkConstants.*; |
30 | 29 |
|
@@ -103,8 +102,74 @@ public void onFinish(ISuite iSuite) { |
103 | 102 | FileHelpers.copyFile("src/test/resources/config/allure/categories.json", "target/allure-results/categories.json"); |
104 | 103 | FileHelpers.copyFile("src/test/resources/config/allure/executor.json", "target/allure-results/executor.json"); |
105 | 104 |
|
| 105 | +// try { |
| 106 | +// // Generate Allure report |
| 107 | +// generateAllureReport(); |
| 108 | +// // Expose the report using ngrok |
| 109 | +// exposeReportWithNgrok(); |
| 110 | +// } catch (IOException | InterruptedException e) { |
| 111 | +// e.printStackTrace(); |
| 112 | +// } |
106 | 113 | } |
107 | 114 |
|
| 115 | +// private void generateAllureReport() throws IOException, InterruptedException { |
| 116 | +// // Run the allure generate command |
| 117 | +// ProcessBuilder pb = new ProcessBuilder("allure.bat", "generate", "target/allure-results", "-o", "allure-report", "--clean"); |
| 118 | +// pb.inheritIO(); // Outputs to console |
| 119 | +// Process process = pb.start(); |
| 120 | +// process.waitFor(); |
| 121 | +// System.out.println("Allure report generated successfully."); |
| 122 | +// } |
| 123 | + |
| 124 | +// private void exposeReportWithNgrok() throws IOException, InterruptedException { |
| 125 | +// // Step 1: Serve the allure-report folder with Python HTTP server (port 8000) |
| 126 | +// ProcessBuilder servePb = new ProcessBuilder("python", "-m", "http.server", "8000"); |
| 127 | +// servePb.directory(new java.io.File(SystemHelpers.getCurrentDir() + "allure-report")); // Set working directory to allure-report |
| 128 | +// servePb.inheritIO(); |
| 129 | +// Process serveProcess = servePb.start(); |
| 130 | +// |
| 131 | +// // Give the server a moment to start |
| 132 | +// Thread.sleep(5000); |
| 133 | +// |
| 134 | +// // Step 2: Start ngrok to expose port 8000 |
| 135 | +// ProcessBuilder ngrokPb = new ProcessBuilder("C:\\ngrok\\ngrok.exe", "http", "8000"); |
| 136 | +// ngrokPb.inheritIO(); |
| 137 | +// Process ngrokProcess = ngrokPb.start(); |
| 138 | +// |
| 139 | +// Thread.sleep(5000); |
| 140 | +// |
| 141 | +// // Đọc và hiển thị đầu ra trong thread riêng |
| 142 | +// new Thread(() -> { |
| 143 | +// try (BufferedReader reader = new BufferedReader(new InputStreamReader(ngrokProcess.getInputStream()))) { |
| 144 | +// String line; |
| 145 | +// while ((line = reader.readLine()) != null) { |
| 146 | +// System.out.println(line); |
| 147 | +// if (line.contains("https://")) { |
| 148 | +// String url = line.split("->")[0].trim().replace("Forwarding", "").trim(); |
| 149 | +// System.out.println("Public URL: " + url); |
| 150 | +// } |
| 151 | +// } |
| 152 | +// } catch (IOException e) { |
| 153 | +// e.printStackTrace(); |
| 154 | +// } |
| 155 | +// }).start(); |
| 156 | +// |
| 157 | +// // Đọc lỗi (nếu có) |
| 158 | +// new Thread(() -> { |
| 159 | +// try (BufferedReader errorReader = new BufferedReader(new InputStreamReader(ngrokProcess.getErrorStream()))) { |
| 160 | +// String line; |
| 161 | +// while ((line = errorReader.readLine()) != null) { |
| 162 | +// System.err.println("ngrok Error: " + line); |
| 163 | +// } |
| 164 | +// } catch (IOException e) { |
| 165 | +// e.printStackTrace(); |
| 166 | +// } |
| 167 | +// }).start(); |
| 168 | +// |
| 169 | +// Thread.sleep(5000); |
| 170 | +// System.out.println("ngrok is running. Check console for the public URL."); |
| 171 | +// } |
| 172 | + |
108 | 173 | public AuthorType[] getAuthorType(ITestResult iTestResult) { |
109 | 174 | if (iTestResult.getMethod().getConstructorOrMethod().getMethod().getAnnotation(FrameworkAnnotation.class) == null) { |
110 | 175 | return null; |
|
0 commit comments