Spring uses Junit
By default, JUnit Jupiter tests are run sequentially in a single thread.
Running tests in parallel — for example, to speed up execution — is available as an experimental feature since version 5.3
Source: https://junit.org/junit5/docs/current/user-guide/#writing-tests-parallel-execution
Using pure Junit
@Execution(ExecutionMode.CONCURRENT)
class MyTest {
@Test
void test1() throws InterruptedException {
Thread.sleep(1000);
System.out.println("Test1 " + Thread.currentThread().getName());
}
@Test
void test2() throws InterruptedException {
Thread.sleep(1000);
System.out.println("Test 2! " + Thread.currentThread().getName());
}
}
source:
Using spring + maven + junit
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
</build>
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = Spring5JUnit4ConcurrentTest.SimpleConfiguration.class)
public class Spring5JUnit4ConcurrentTest implements ApplicationContextAware, InitializingBean {
@Configuration
public static class SimpleConfiguration {}
private ApplicationContext applicationContext;
private boolean beanInitialized = false;
@Override
public void afterPropertiesSet() throws Exception {
this.beanInitialized = true;
}
@Override
public void setApplicationContext(
final ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
@Test
void test1A() {
System.out.println(Thread.currentThread().getName()+" => test1A");
}
@Test
void test1B() {
System.out.println(Thread.currentThread().getName()+" => test1B");
}
@Test
void testC() {
System.out.println(Thread.currentThread().getName()+" => test1C");
}
}
Sources:
Simple tests are "almost parallel"
According to this and my tests, simple junit tests are executed almost parallel
public class Hello1Test {
@Test
public void myTest() throws Exception {
System.out.println(new Date());
assertTrue(true);
}
}
mvn test

NOTE: If you add some Thread related in the test, they are executed sequentially
@Test
public void myTest() throws Exception {
System.out.println(new Date());
Thread.sleep(2000);
assertTrue(true);
}

Exclude some tests
According to this you could use -Dtest to pick or exclude specific tests
- mvn test -q
- mvn test -q -Dtest='Hello1*'
- run only test with name Hello1*
- mvn test -q -Dtest='!Hello1*, !Hello2*'
- run all tests except Hello1* and Hello2*

Tips