Merge pull request #2957 from asturcon/tutorials/runWithJUnit5

@RunWith in JUnit5
This commit is contained in:
lor6 2017-11-04 16:38:19 +02:00 committed by GitHub
commit 582147e7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

@ -29,6 +29,7 @@
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
<junit4.version>4.12</junit4.version>
<spring.version>5.0.1.RELEASE</spring.version>
</properties>
<build>
@ -111,6 +112,17 @@
<version>${junit4.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>

View File

@ -0,0 +1,21 @@
package com.baeldung.junit5.spring;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import com.baeldung.junit5.Greetings;
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = { SpringTestConfiguration.class })
public class GreetingsSpringTest {
@Test
void whenCallingSayHello_thenReturnHello() {
assertTrue("Hello".equals(Greetings.sayHello()));
}
}

View File

@ -0,0 +1,8 @@
package com.baeldung.junit5.spring;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SpringTestConfiguration {
}