Last active
          January 2, 2023 13:22 
        
      - 
      
 - 
        
Save dnno/3ce96e517a812e0f9c6c92c2f85a258c to your computer and use it in GitHub Desktop.  
    JUnit5 provider test with broker integration
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | |
| @Provider("UserServiceJUnit5") | |
| @PactBroker(url = "http://localhost:9292") | |
| @SetSystemProperty(key = "pact.verifier.publishResults", value = "true") | |
| public class PactProviderJUnit5WithBrokerTest { | |
| @LocalServerPort | |
| int port; | |
| @BeforeEach | |
| public void setup(PactVerificationContext context) { | |
| context.setTarget(new HttpTestTarget("localhost", port)); | |
| } | |
| @State("A running user service") | |
| void setupUserService() { | |
| // no state setup ATM | |
| } | |
| @TestTemplate | |
| @ExtendWith(PactVerificationInvocationContextProvider.class) | |
| void pactVerificationTestTemplate(PactVerificationContext context) { | |
| context.verifyInteraction(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment