mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-12 16:15:23 +00:00
fix: Fix test stability issues
This commit is contained in:
1 parent
13cde46f2e
commit
177dc52704
24 files changed
+253
-111
No files matched your search
@@ -44,6 +44,11 @@ public class App {
|
||||
* @param args command line args
|
||||
*/
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(App.class, args);
|
||||
var context = SpringApplication.run(App.class, args);
|
||||
if (args.length > 0 && "test".equals(args[0])) {
|
||||
// Close the context immediately during tests to prevent Tomcat/background threads from
|
||||
// hanging the JVM
|
||||
context.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,6 @@ import org.junit.jupiter.api.Test;
|
||||
public class AppTest {
|
||||
@Test
|
||||
void shouldExecuteApplicationWithoutException() {
|
||||
assertDoesNotThrow(() -> App.main(new String[] {}));
|
||||
assertDoesNotThrow(() -> App.main(new String[] {"test"}));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user