-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathTestService.java
More file actions
28 lines (28 loc) · 1.21 KB
/
Copy pathTestService.java
File metadata and controls
28 lines (28 loc) · 1.21 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
package com.microservices.example.web;
import com.rest.api.test.ArithmeticIntegrationTest;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.util.logging.Logger;
import org.springframework.stereotype.Service;
@Service
public class TestService {
protected Logger logger = Logger.getLogger(TestService.class.getName());
public String runAllTests() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintStream printStream = new PrintStream(outputStream);
PrintStream originalOut = System.out;
try {
System.setOut(printStream);
logger.info("Running all integration tests.");
ArithmeticIntegrationTest.main(new String[]{}); // Run the integration tests
System.out.flush();
logger.info("Integration tests executed successfully.");
} catch (Exception e) {
logger.severe("Error occurred while running integration tests: " + e.getMessage());
logger.severe("Stack Trace: " + e.getStackTrace());
} finally {
System.setOut(originalOut);
}
return outputStream.toString(); // Return the captured output
}
}