@PactBroker not reading Spring properties with JUnit 5
See original GitHub issueIf you provide system properties in Spring application.yml
these won’t be read by the @PactBroker
annotation when running with JUnit 5. This works fine if you provide them as normal system properties.
This issue seems to have been fixed for the JUnit 4 runners in here: https://github.com/DiUS/pact-jvm/issues/632
I can see that the problem has been fixed by adding a property resolver, and that it is also possible to pass a valueResolver
attribute for the @PactBroker
annotation. However, since you need a Spring context to be able to create such a resolver for Spring, it cannot be done with the annotation.
I also tried to add a resolver into PactVerificationContext
in @BeforeEach
but that didn’t seem to do the trick.
Issue Analytics
- State:
- Created 4 years ago
- Comments:19 (11 by maintainers)
Top Results From Across the Web
PactBroker not reading Spring properties with JUnit 5 #1023
If you provide system properties in Spring application.yml these won't be read by the @PactBroker annotation when running with JUnit 5.
Read more >Provider test integration with pact broker for Spring Boot junit5 ...
However, @PactBroker annotation depends on the system properties. Is there a way to get this working for application properties via the Spring ......
Read more >Pact junit runner | Pact Docs
Rule JUnit annotations, that will be run before/after each test of ... The pact broker loader was updated to allow system properties to...
Read more >Consumer Tests with Pact, Junit5, SpringBoot - Level Up Coding
The following makes use of with Java, Spring and Junit5. ... You can use a pact broker to house and serve up pact...
Read more >“How-to” Guides - Spring
Flow: Consumer Contract Approach with Pact Broker on the Producer Side; 7.9. ... the JUnit 4 rule, JUnit 5 extension, or properties, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve created a new module pact-jvm-provider-junit5-spring with a TestTemplateInvocationContextProvider that extends the current JUnit 5 one (PactVerificationSpringProvider). This should allow you to configure all the properties in the Spring context.
Sure, sorry. In the documentation, it says
So, the
PactVerificationSpringProvider
is used on the method but not on the class. This does not allow me to load e.g.pactbroker.host
from theapplication.yaml
. Instead, I need to do something like this