Skip to content

Commit c7c3d82

Browse files
author
eugenp
committed
testing work with JUnit 5
1 parent d67ace8 commit c7c3d82

4 files changed

Lines changed: 85 additions & 1 deletion

File tree

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
server.port=8081
22

33
security.user.name=user
4-
security.user.password=pass
4+
security.user.password=pass
5+
6+
logging.level.root=INFO
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.baeldung;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class IntegrationTestExample1 {
11+
12+
@Test
13+
public void test1a() {
14+
block(3000);
15+
}
16+
17+
@Test
18+
public void test1b() {
19+
block(3000);
20+
}
21+
22+
public static void block(long ms) {
23+
try {
24+
Thread.sleep(ms);
25+
} catch (InterruptedException e) {
26+
System.out.println("Thread interrupted");
27+
}
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.baeldung;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class IntegrationTestExample2 {
11+
12+
@Test
13+
public void test1a() {
14+
block(3000);
15+
}
16+
17+
@Test
18+
public void test1b() {
19+
block(3000);
20+
}
21+
22+
public static void block(long ms) {
23+
try {
24+
Thread.sleep(ms);
25+
} catch (InterruptedException e) {
26+
System.out.println("Thread Interrupted");
27+
}
28+
}
29+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung;
2+
3+
import org.junit.Test;
4+
import org.junit.experimental.ParallelComputer;
5+
import org.junit.runner.Computer;
6+
import org.junit.runner.JUnitCore;
7+
8+
public class ParallelTestExample {
9+
10+
@Test
11+
public void runTests() {
12+
final Class<?>[] classes = { IntegrationTestExample1.class, IntegrationTestExample2.class };
13+
14+
JUnitCore.runClasses(new Computer(), classes);
15+
}
16+
17+
@Test
18+
public void runTestsInParallel() {
19+
final Class<?>[] classes = { IntegrationTestExample1.class, IntegrationTestExample2.class };
20+
21+
JUnitCore.runClasses(new ParallelComputer(true, true), classes);
22+
}
23+
24+
}

0 commit comments

Comments
 (0)