forked from karatelabs/karate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBase.java
More file actions
32 lines (26 loc) · 746 Bytes
/
TestBase.java
File metadata and controls
32 lines (26 loc) · 746 Bytes
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
package demo;
import org.junit.jupiter.api.BeforeAll;
import test.ServerStart;
/**
*
* @author pthomas3
*/
public abstract class TestBase {
static ServerStart server;
public static int startServer() {
if (server == null) { // keep spring boot side alive for all tests including package 'mock'
server = new ServerStart();
try {
server.start(new String[]{"--server.port=0"}, false);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
System.setProperty("demo.server.port", server.getPort() + "");
return server.getPort();
}
@BeforeAll
public static void beforeAll() {
startServer();
}
}