testing work with JUnit 5
This commit is contained in:
parent
d67ace8e1e
commit
c7c3d822d9
|
@ -1,4 +1,6 @@
|
|||
server.port=8081
|
||||
|
||||
security.user.name=user
|
||||
security.user.password=pass
|
||||
security.user.password=pass
|
||||
|
||||
logging.level.root=INFO
|
|
@ -0,0 +1,29 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class IntegrationTestExample1 {
|
||||
|
||||
@Test
|
||||
public void test1a() {
|
||||
block(3000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1b() {
|
||||
block(3000);
|
||||
}
|
||||
|
||||
public static void block(long ms) {
|
||||
try {
|
||||
Thread.sleep(ms);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Thread interrupted");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class IntegrationTestExample2 {
|
||||
|
||||
@Test
|
||||
public void test1a() {
|
||||
block(3000);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test1b() {
|
||||
block(3000);
|
||||
}
|
||||
|
||||
public static void block(long ms) {
|
||||
try {
|
||||
Thread.sleep(ms);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Thread Interrupted");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.ParallelComputer;
|
||||
import org.junit.runner.Computer;
|
||||
import org.junit.runner.JUnitCore;
|
||||
|
||||
public class ParallelTestExample {
|
||||
|
||||
@Test
|
||||
public void runTests() {
|
||||
final Class<?>[] classes = { IntegrationTestExample1.class, IntegrationTestExample2.class };
|
||||
|
||||
JUnitCore.runClasses(new Computer(), classes);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void runTestsInParallel() {
|
||||
final Class<?>[] classes = { IntegrationTestExample1.class, IntegrationTestExample2.class };
|
||||
|
||||
JUnitCore.runClasses(new ParallelComputer(true, true), classes);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue