-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathTestController.java
More file actions
26 lines (26 loc) · 1.11 KB
/
Copy pathTestController.java
File metadata and controls
26 lines (26 loc) · 1.11 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
package com.microservices.example.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.logging.Logger;
@Controller
public class TestController {
@Autowired
private TestService testService;
protected Logger logger = Logger.getLogger(TestController.class.getName());
@RequestMapping("/run-tests")
public String runTests(Model model) {
try {
logger.info("Triggering test execution.");
String results = testService.runAllTests();
model.addAttribute("results", results);
logger.info("Test execution completed successfully.");
} catch (Exception e) {
logger.severe("Error occurred while running tests: " + e.getMessage());
logger.severe("Stack Trace: " + e.getStackTrace());
model.addAttribute("results", "Error occurred while running tests. Please check the logs.");
}
return "testResults";
}
}