diff --git a/provider/pact-jvm-provider-junit5-spring/build.gradle b/provider/pact-jvm-provider-junit5-spring/build.gradle index 6e1c6b0137..d6c57ab266 100644 --- a/provider/pact-jvm-provider-junit5-spring/build.gradle +++ b/provider/pact-jvm-provider-junit5-spring/build.gradle @@ -2,4 +2,7 @@ dependencies { implementation project(path: ":provider:pact-jvm-provider-junit5", configuration: 'default') implementation 'org.springframework:spring-context:5.2.3.RELEASE' implementation 'org.springframework:spring-test:5.2.3.RELEASE' + + testImplementation 'org.springframework.boot:spring-boot-starter-test:2.2.5.RELEASE' + testImplementation 'org.springframework.boot:spring-boot-starter-web:2.2.5.RELEASE' } diff --git a/provider/pact-jvm-provider-junit5-spring/src/test/kotlin/au/com/dius/pact/provider/spring/junit5/PactVerificationSpringProviderTest.kt b/provider/pact-jvm-provider-junit5-spring/src/test/kotlin/au/com/dius/pact/provider/spring/junit5/PactVerificationSpringProviderTest.kt new file mode 100644 index 0000000000..5c6bf62175 --- /dev/null +++ b/provider/pact-jvm-provider-junit5-spring/src/test/kotlin/au/com/dius/pact/provider/spring/junit5/PactVerificationSpringProviderTest.kt @@ -0,0 +1,27 @@ +package au.com.dius.pact.provider.spring.junit5 + +import au.com.dius.pact.provider.junit.IgnoreNoPactsToVerify +import au.com.dius.pact.provider.junit.Provider +import au.com.dius.pact.provider.junit.loader.PactBroker +import au.com.dius.pact.provider.junit5.PactVerificationContext +import org.junit.jupiter.api.TestTemplate +import org.junit.jupiter.api.extension.ExtendWith +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit.jupiter.SpringExtension + +@SpringBootApplication +open class TestApplication + +@ExtendWith(SpringExtension::class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Provider("Animal Profile Service") +@PactBroker +@IgnoreNoPactsToVerify +internal class PactVerificationSpringProviderTest { + @TestTemplate + @ExtendWith(PactVerificationSpringProvider::class) + fun pactVerificationTestTemplate(context: PactVerificationContext?) { + context?.verifyInteraction() + } +} diff --git a/provider/pact-jvm-provider-junit5-spring/src/test/resources/application.yml b/provider/pact-jvm-provider-junit5-spring/src/test/resources/application.yml new file mode 100644 index 0000000000..3115ba717b --- /dev/null +++ b/provider/pact-jvm-provider-junit5-spring/src/test/resources/application.yml @@ -0,0 +1,3 @@ +pactbroker: + host: localhost + port: ${local.server.port}