made junit5 default test generation framework (#1320)

fixes #1249
This commit is contained in:
Marcin Grzejszczak
2020-02-07 13:43:30 +01:00
committed by GitHub
parent a48c491bfd
commit eeb2d87c14
72 changed files with 487 additions and 252 deletions

View File

@@ -41,11 +41,14 @@ dependencies {
testImplementation 'org.springframework.cloud:spring-cloud-contract-wiremock'
testImplementation 'org.springframework.cloud:spring-cloud-starter-contract-stub-runner'
testImplementation "org.springframework.boot:spring-boot-starter-test"
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
testImplementation "com.example:http-server-restdocs:0.0.1:stubs"
}
test {
useJUnitPlatform()
systemProperty 'spring.profiles.active', 'gradle'
testLogging {
exceptionFormat = 'full'

View File

@@ -60,6 +60,12 @@
<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>
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -24,20 +24,20 @@ import com.example.loan.model.LoanApplicationResult;
import com.example.loan.model.LoanApplicationStatus;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.core.io.Resource;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StreamUtils;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "service.port=${wiremock.server.port}")
@AutoConfigureWireMock(port = 0)
public class LoanApplicationServiceTests {

View File

@@ -20,19 +20,19 @@ import com.example.loan.model.Client;
import com.example.loan.model.LoanApplication;
import com.example.loan.model.LoanApplicationResult;
import com.example.loan.model.LoanApplicationStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = "com.example:http-server-restdocs")
public class LoanApplicationServiceusingStubRunnerTests {
@@ -43,7 +43,7 @@ public class LoanApplicationServiceusingStubRunnerTests {
@Value("${stubrunner.runningstubs.http-server-restdocs.port}")
int port;
@Before
@BeforeEach
public void setup() {
this.service.setPort(this.port);
}

View File

@@ -22,8 +22,8 @@ import java.nio.charset.Charset;
import com.github.tomakehurst.wiremock.WireMockServer;
import com.github.tomakehurst.wiremock.stubbing.StubMapping;
import org.assertj.core.api.BDDAssertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -33,11 +33,11 @@ import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.StreamUtils;
import org.springframework.web.client.RestTemplate;
@RunWith(SpringRunner.class)
@SpringBootTest(properties = "service.port=${wiremock.server.port}")
@AutoConfigureWireMock(port = 0)
public class XmlServiceTests {

View File

@@ -19,8 +19,8 @@ package com.example.loan;
import java.net.URI;
import org.assertj.core.api.BDDAssertions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
@@ -28,10 +28,10 @@ import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRun
import org.springframework.http.MediaType;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureStubRunner(ids = "com.example:http-server-restdocs")
public class XmlServiceUsingStubRunnerTests {