Running
mvn -U clean verify install -Djava.awt.headless=true -Dtest=MainTestSuite -DfailIfNoTests=false -Dmaven.test.failure.ignore=true
mvn test -Dcucumber.options=”src/test/java/Features/smoketest.feature.
Gherkin lenguaje
Spring Boot projects with versions >= 2.2.0 use JUnit 5 by default.
Description | JUnit 4 | JUnit 5 |
---|---|---|
Test Annotation Changes | @Before @After @BeforeClass @AfterClass @Ignore |
@BeforeEach @AfterEach @BeforeAll @AfterAll @Disabled |
Use @ExtendWith instead of @RunWith |
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(MockitoJUnitRunner.class) |
@ExtendWith(SpringExtension.class) @ExtendWith(MockitoExtension.class) |
Package changes to org.junit.jupiter |
org.junit.Test; org.junit.Assert.*; |
org.junit.jupiter.api.Test; org.junit.jupiter.api.Assertions.*; |
@RunWith is NOT needed with @SpringBootTest , @WebMvcTest , @DataJpaTest |
@RunWith(SpringRunner.class) @SpringBootTest(classes = DemoApplication.class) |
@SpringBootTest(classes = DemoApplication.class) |
- JPA - https://github.com/in28minutes/jpa-with-hibernate/commit/0ae2007c8e08420e6d5ab2a86499274c7c60c8ae
- Unit Testing with Spring Boot - https://github.com/in28minutes/spring-unit-testing-with-junit-and-mockito/commit/2c6df429aec248d455b7ad19e60e90743979ba1c
- Spring Framework - https://github.com/in28minutes/spring-master-class/commit/60b61500f8f80517ef86d50e7dffb5826b2b3720
Spring Boot projects with versions >= 2.2.0 use JUnit 5 by default. You should see something like this in your pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
<dependency>
- JUnit - https://junit.org/junit5/docs/current/user-guide/
- AssertJ - https://joel-costigliola.github.io/assertj/
- Mockito - https://github.com/mockito/mockito/wiki/FAQ
- JsonPath - https://github.com/json-path/JsonPath
- Setting up JUnit 5 with Mockito and Spring Boot 2.0 - https://medium.com/@dSebastien/using-junit-5-with-spring-boot-2-kotlin-and-mockito-d5aea5b0c668
- Good Unit Testing
- Mocking Static, Private Methods and Constructors