Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PactSource annotation only at test-class level #1237

Closed
jnowakowskiWR opened this issue Oct 26, 2020 · 2 comments
Closed

PactSource annotation only at test-class level #1237

jnowakowskiWR opened this issue Oct 26, 2020 · 2 comments

Comments

@jnowakowskiWR
Copy link

PactSource at custom annotation level

Right now, if you create a custom annotation for your tests you have to pass PactSource annotation at the test-class level, instead of your annotation, or the exception will be thrown:

At least one pact source must be present on the test class
java.lang.UnsupportedOperationException: At least one pact source must be present on the test class
	at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.findPactSources(PactJUnit5VerificationProvider.kt:505)
	at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:459)
	at au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:426)
	at org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:102)
	at java.base/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:271)

Current behavior:

@ContractTest
@Consumer("consumer")
@PactBroker
class ProviderConsumerTest {
}
@Target(value = ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith({
        SpringExtension.class,
        MockitoExtension.class,
        PactVerificationInvocationContextProvider.class
})
@Provider("provider")
public @interface ContractTest {
}

Expected behaviour

@ContractTest
@Consumer("consumer")
class ProviderConsumerTest {
}
@Target(value = ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith({
        SpringExtension.class,
        MockitoExtension.class,
        PactVerificationInvocationContextProvider.class
})
@Provider("provider")
@PactBroker
public @interface ContractTest {
}

Please fix PactSource annotation processing, so the PactSource can be passed in the custom annotation

@uglyog
Copy link
Member

uglyog commented Nov 6, 2020

Version 4.1.10 has been released with this

@jnowakowskiWR
Copy link
Author

Great work! Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants