- 27
- 293 438
PactFlow
เข้าร่วมเมื่อ 31 พ.ค. 2020
pactflow.io content and instructional videos
PactFlow gRPC contract testing demo
gRPC and Protobufs are increasing in popularity, however, there are multiple classes of problems that may result in API breaking changes. In this video, we show how you can apply contract testing to gRPC and Protobufs systems using Pact and its Plugin framework.
We cover:
0:20 - Example introduction: The Area Calculator
0:47 - Installing the Pact Plugin CLI
1:18 - Creating a gRPC consumer contract test in Java
2:35 - Publishing the contract and viewing in PactFlow
3:35 - Verifying a gRPC contract test in Java
For an in-depth view of this, see pactflow.io/blog/contract-testing-for-grpc-and-protobufs/
We cover:
0:20 - Example introduction: The Area Calculator
0:47 - Installing the Pact Plugin CLI
1:18 - Creating a gRPC consumer contract test in Java
2:35 - Publishing the contract and viewing in PactFlow
3:35 - Verifying a gRPC contract test in Java
For an in-depth view of this, see pactflow.io/blog/contract-testing-for-grpc-and-protobufs/
มุมมอง: 1 674
วีดีโอ
Feature Demo: Can I Deploy
มุมมอง 2.3K2 ปีที่แล้ว
Check our Can I Deploy in the Pactflow UI Can I Deploy is the promised land for contract testers! The much-loved feature in Pactflow is now available in our UI, improving visibility into which applications can be deployed and why. In this demo, Shuying shows you how to use Can I Deploy in the UI. Already got a Pactflow account? Learn more at pactflow.io/blog/can-i-deploy/ or see Can I Deploy in...
Using OpenAPI Documentation in Contract Testing with Pactflow
มุมมอง 7K2 ปีที่แล้ว
Get more of your team involved and maintain traction to ensure a successful rollout of your contract testing initiative using OpenAPI Documentation. Using the consumer driven Pact contract testing framework gives development teams the confidence to deploy more often, move faster and save time and money maintaining E2E test suites. While the outcomes are great, in some instances, contract testin...
Using Cypress and Postman for Contract Testing with Pactflow
มุมมอง 3.8K2 ปีที่แล้ว
Increase the quality outcomes faster and get the whole team can get involved with contract testing using Cypress and Postman. As a tester, your role is to ensure quality, shorten feedback loops and promote shift-left testing activities such as contract testing. However, as a white-box testing tool, consumer driven contract testing using the Pact framework requires access to the source code and ...
Introducing Bi-Directional Contract Testing
มุมมอง 9362 ปีที่แล้ว
Say hello to Bi-Directional Contract Testing-a new feature, exclusive to Pactflow, enabling teams to get value from contract testing faster! Bi-Directional Contract Testing enables new modes of contract capture and compliance, a broader set of use cases, and a simplified developer experience. With Bi-Directional Contract Testing, Pactflow customers can “upgrade” their existing tools into a powe...
Bi-Directional Contract Testing: What is it and how it works
มุมมอง 5K2 ปีที่แล้ว
Say hello to Bi-Directional Contract Testing-a new feature, exclusive to Pactflow, enabling teams to get value from contract testing faster! Bi-Directional Contract Testing enables new modes of contract capture and compliance, a broader set of use cases, and a simplified developer experience. With Bi-Directional Contract Testing, Pactflow customers can put their favourite tools to work to creat...
Bi-Directional Contract Testing: Demo using OpenAPI Spec
มุมมอง 4.6K2 ปีที่แล้ว
Say hello to Bi-Directional Contract Testing-a new feature, exclusive to Pactflow, enabling teams to get value from contract testing faster! Bi-Directional Contract Testing enables new modes of contract capture and compliance, a broader set of use cases, and a simplified developer experience. With Bi-Directional Contract Testing, Pactflow customers can put their favourite tools to work to creat...
Rolling out contracting testing Pactflow at M1 Finance
มุมมอง 2333 ปีที่แล้ว
Learn how M1 Finance rolled out contract testing with Pactflow, featuring M1's Head of Test Engineering, Bedford West. M1 Finance (M1) is a Chicago-based personal financial app providing automated investing, borrowing, and banking products to hundreds of thousands of Americans. Founded in 2015, M1 Finance is a hypergrowth FinTech-having recently hit a USD1.45 billion valuation and USD5B assets ...
[Advanced contract testing with Pact] Best practices for writing consumer tests
มุมมอง 17K3 ปีที่แล้ว
[Advanced contract testing with Pact] Best practices for writing consumer tests
[Contract testing 'Ask Me Anything' with Pactflow] APAC on 28 Apr 2021
มุมมอง 4603 ปีที่แล้ว
[Contract testing 'Ask Me Anything' with Pactflow] APAC on 28 Apr 2021
[Contract testing 'Ask Me Anything' with Pactflow] North America on 27 Apr 2021
มุมมอง 2773 ปีที่แล้ว
[Contract testing 'Ask Me Anything' with Pactflow] North America on 27 Apr 2021
[Contract testing 'Ask Me Anything' with Pactflow] UK / EU on 22 Apr 2021
มุมมอง 7773 ปีที่แล้ว
[Contract testing 'Ask Me Anything' with Pactflow] UK / EU on 22 Apr 2021
[Introduction to contract testing - Part 4] How do I remove end-to-end tests?
มุมมอง 20K3 ปีที่แล้ว
[Introduction to contract testing - Part 4] How do I remove end-to-end tests?
[Introduction to contract testing - Part 1] The problem with end-to-end integrated tests
มุมมอง 59K3 ปีที่แล้ว
[Introduction to contract testing - Part 1] The problem with end-to-end integrated tests
[Introduction to contract testing - Part 2] Contract testing and how Pact works
มุมมอง 115K3 ปีที่แล้ว
[Introduction to contract testing - Part 2] Contract testing and how Pact works
[Introduction to contract testing - Part 3] Demo - Contract testing with Pact JS
มุมมอง 48K3 ปีที่แล้ว
[Introduction to contract testing - Part 3] Demo - Contract testing with Pact JS
Watched your first 3 videos and am cursing myself for not picking this topic earlier :). Great demo! Looking forward to explore all content on this and try this out.
Thanks for the kind words, best of luck with contract testing!
Great video! It well explains a complex problem and its solution. I wonder if there are any test coverage tools or quality gates available? Use case: In our project, we have already implemented some Pact tests, and now a new change is being added-a new field to the DTO. The repositories are isolated: one for the backend and another for the front end. The first step is completed on the backend, followed by the addition of a new feature on the front end. Is it possible to establish a quality gate that will prevent my pull request to front-end from being merged without proper Pact tests?
Hi, can we run only producer driven contract test using bi directional contracts? Without creating consumer driven contract
No, PactFlow requires a consumer test to compare against also.
Now I am confused about Pending vs WIP...
Oh no, the whole point of the AMA was to clarify that - what's not clear?
@@PactFlow it's ok found more info somewhere else.
What does "BYO" mean?
Bring your own. In this case it means you need to use another tool to perform testing of the API and PactFlow will ensure compatibility with the consumer
one thing I am not able to figure out I understand that one usage of pact is to support the consumer development even if the backend is not ready .. and this will be through the mock service. however, i can see from the tutorial is the that the mock service is only run in order to execute the consumer test against it. and once the test is finished it is brought down again (stopped) hence how can the mock server be up with this mock service running during the consumer development?? kindly let me know if I anything is wrong from the above.
There are two primary benefits 1. Is to allow you to write tests for the APIs that don't even exists (e.g. TDD for services) 2. You can use the contracts as stubs too: docs.pact.io/getting_started/stubs
Why does the consumer dictate the rules? What if a producer have multiple consumers and every consumer wants different things from the producer? I think the producer should dictate rules by generating a pack then consumers can get pacts and test expectations.
That approach is more provider-driven. Consumer-driven testing doesn't mean the consumer dictates the structure, but it allows the consumers to start documenting their assumptions about the provider before it even exists. The provider always has the right to decline bad assumptions, and Pact has ways to handle this - that is, a Provider won't be held hostage to a set of bad consumers. If it helps, it's a theoretical problem I've never seen in practice in the 10+ years of Pact. You may also like to see our bi-directional testing capability, which supports a design-first or provider-driven workflow (leveraging OpenAPI as part of a "provider contract": docs.pactflow.io/docs/bi-directional-contract-testing)
@@PactFlow got it. so there are different approaches. I'll examine them. thanks for care.
@@basibosturk You're welcome. The best thing to do is give it a go and see what you think. Good luck!
and can it be used to test non functional and repeatitve tests ... like testing the consumer quota ... CORS options, etc ...
No, that's not what contract testing is about. See also docs.pact.io/consumer/contract_tests_not_functional_tests
and is there any way to expedite writing the contract (i.e. test cases) ... because I believe it is a bit verbose
Contract testing is more than just ensuring breaking changes. The tests themselves are like any other good test - they apply stress to the design and structure of your code. If Pact tests are hard to write, that is a sign that your code is not very testable and modular and should be improved. There are ways to generate tests though, but you should only consider this once you know what you're doing. You may also like our bi-directional contract testing feature which simplifies this workflow / allows you to re-use mocks and existing testing tools: docs.pactflow.io/docs/bi-directional-contract-testing
does the example mentioned mean that it will test against the provider with order id = 10 ? what it the provider (its SOR actually) doesnt contain and order with this ID? or what if it returns data with values other than the values stored in the repository contract ? is there an option to set these values dynamically so that the values while mock testing the consumer is different than these while testing the real provider ?
Yes, there are two Pact ways to handle this - the use of Provider States and the use of generators. This is one of the neat ways Pact works around the "data fixture" issue. See docs.pact.io/getting_started/terminology#provider-state, docs.pact.io/provider/using_provider_states_effectively and example of dynamic values from the provider here: pactflow.io/blog/injecting-values-from-provider-states/
Can we publish contracts for consumer in java even if my consumer logic is in react
Yes, publishing a contract is independent of how the contract is generated.
@@fattymellows I mean my consumer logic is written in react . Can I write consumer bi directional test case in java language to generate pact file ?
Yes, Pact is a popular and effective tool for contract testing of REST APIs ChatGPT verified Ok. Cracket that
You mentioned you don't need a dedicated test environment, how would you cater for a hybrid scenario where you want to test an API in a monolith application that also calls a microservice from the provider pov?
Regarding Postman, I've had success in the past drawing fresh data into variables, for example exchange rates and product prices, using a pre-execution script. This leads the tests to be less brittle. I'm just starting to look at Pact.
I think this point is similar to the one made below about "garbage in - garbage out". Sure, there are ways to improve this situation and at a small scale it might be workable, but the reality is that data setup is a costly exercise especially as the size of the ecosystem you're testing grows. You need to know the implementation details of the systems far beyond the direct SUT which at some point becomes unmanageable.
I have a question about the mock definition. In this example it was defined by the consumer in its unit test. Is it supposed to work this way in real life or was it for the purpose of the example ? I would expect that a mock would be defined beforehand so that the consumer's request is tested too.
Great demo, looks very useful. Do you support AsyncAPI for messaging as well?
It's on our longer term roadmap, but we don't currently support it in this flow. We do support messaging in the standard consumer-driven flow with Pact however
Well its just a contract testing we can place it in the testing pyramid between unit tests and integration tests and move one - geez
I'm sorry, is there a point you're trying to make? The video is to help people understand what contract testing is and how it works.
Can we publish contracts for both provider and consumer by using only cypress ?
No, you can only publish consumer contracts this way.
Hi Thanks for clear explanation. I have one quick question regarding wiremock-pact-generator. The pact file which is generated by wiremock pact generator plugin is not having pact matchers and states. Will that be fine? I have asked similar question in stackoverflow, how can we add the states in wiremock pact generator, and I have got a response from your saying that pact generator is not fully generating contract as per pact standard as it won't generate pact matcher which are important to verify. I surprised seeing example with wiremock pact generator here.
As discussed in your SO post, matchers aren't using in BDCT (docs.pactflow.io/docs/bi-directional-contract-testing) so not generating them in this way is not a problem. Only the example request/response cycles are needed for BDCT as a consumer contract.
Excellent info ..Thanks a lot
when considering wip pact, will we consider content hash as well? Otherwise, I am just bit worried there could be too many WIP pacts for provider to verify prematurely
Yes, I believe the Broker will de-duplicate them based on uniqueness
Sir, please zoom in next time, otherwise I need to go fullscreen which is a nightmare
I can relate a lot with the commit message at 3:57 "satisfy my OCD"
🤣
How to configure the branches for the applications?
In general, I would recommend reading this guide: docs.pact.io/pact_nirvana Branches get set on publishing a contract (using the Pact CLI tools) or verifying pacts (on the verification configuration settings of your provider). They should be sourced from the git repository during the build.
Hi I am having issues with understanding what to define in the providerstates when creating a interaction via consumer. So it is all good when the domain model in frontend almost has a 1-1 mapping with the backend but it is difficult to understand once the frontend requets a data object that is not pure in the backend but rather build but different sub resources that the frontend (should not and do not want to care about). How should you define providerstates in that case?
Think of provider states as a precondition for the consumer test to pass (e.g. "user is authenticated" or "user has a positive credit balance"). The states shouldn't have implementation details in them, it is up to the provider to determine how to implement a provider state handler. The provider could seed a database (if it's a 1:1 mapping) or stub a 3rd party API if it's further downstream.
Does the linked github source runs now too? I have Node js (no python). Please confirm
Yes, of course! If you have an issue, please raise it on the linked github repo so we can look into it.
fantastic demo. gonna try it now
If the whole process can be visualize it would be great
Very useful
The chart at the end of the video is amazing, however, the youtube suggestions (next video and channel) really hinder it. Especially when you have all the curves on it.
Argh, very sorry about that!
Maybe I missed something, but: 1) You pushed the changes in the consumer 2) can-i-deploy failed cause the provider doesn't comply with the new pact, thus we don't push any breaking changes cause they don't get to go to prod 3) You pushed the changes in the provider, these ones did go to prod, yet the consumer hasn't yet. If I were not to deploy the consumer right afterwards/at the same time, how is this not a breaking change? Wouldn't, at this point in the process, a request from the consumer fail since the provider is now expecting something different? Asking cause I was under the impression that contract-testing with Pact would help not to deploy stuff all-at-once having to release different services altogether, and although this helps a bit, how is this not that? Am I missing something about how Pact works?
All this in the event of changing the contract itself, for example, at the end you remove the "name" var, the code fails and bla bla... But what if you wanted the contract to change so that it didn't include the name var anymore?
Yes, I think you are missing something. The provider can deploy to production because no consumer is in production yet. Once the provider and consumer are both in production (or any shared environment) Pact won't let you push a breaking change to either of them.
@@FacuConejero-wh8wt That would be a breaking change if the consumer relied on that property. But your general point - Pact is designed to prevent you from having to simultaneously release changes. In fact, you would have to work around the tooling to get yourself into a situation where that is necessary.
I don't get it why optional attributes are not supported. It is quite natural that you have that in a response. For example a json response could return an array of objects and for some objects a certain field is set and some other objects it is not set. This does not mean that I "dont have control of the response" but just that the response is naturally like that and I want it to be like that because that is how the business rules are, which generates the JSON response. To say that Pact test is then not suitable for that I would say is the same as saying that most scenarios, involving complex JSON objects, are not suitable for Pact testing.
See docs.pact.io/faq#why-is-there-no-support-for-specifying-optional-attributes for why Pact doesn't support optional attributes. We understand in the real world data is modelled in complex ways, but we need to be able to provide guarantees. This is hard to do if we haven't tested each case explicitly. Pactflow's bi-directional contract testing supports this sort of schema check (docs.pactflow.io/docs/bi-directional-contract-testing/) however because of that type of test, the guarantees aren't as strong. This is why we have both offerings.
Can you also make similar video but using web app as a consumer, please?
Hi Robert! We don't have any plans at the moment but thanks for your request. What would you be hoping to see?
Check out th-cam.com/video/tl1PtesLJVI/w-d-xo.html
Although this users Cypress with a Pact adapter, you can use the Pact framework directly with something like Pact-JS which is preferred and will avoid a layer of indirection 👍
Good job!!
I'm a bit confused with the example given from the provider side. Is the Pact verifier checking against the provider or a mocked response from the provider? If so, surely your argument about the other dependant services falls a bit short as the provider is still potentially running against those other services? I can see the value in the consumer side though
Actually I think its nonsense what I've put there.. as at the time this is tested you'd have the consumer up and running as part of the build pipeline right?
It is recommended to stub out external systems as part of contract testing (see also docs.pact.io/5-minute-getting-started-guide#scope-of-a-provider-pact-test and docs.pact.io/provider#stub-calls-to-downstream-systems). This increases the reliability of those tests and makes them more unit test-like. Of course, if they are other APIs, you should have a separate set of contract tests to cover those, and so on until you reach a leaf node. -Matt
I'm not sure I understood the second question, but we'd be happy to chat in more detail over at slack.pact.io and clarify any questions you have. P.S. you have the voice of an angel 🎶
1. We still need to deploy the actual Provider to run provider tests. right ? so why we say it is equivalent to unit? 2. What we do to the Provider dependencies ?
No, the provider should be tested in a unit test-like context and not in a deployed environment. It should be able to run on your development machine - this is how you get the fast, reliable feedback. Deploying to an environment makes it more of an end-to-end / functional test, which we are trying to avoid with contract testing. This means any dependencies should be stubbed out, and they should then have their own set of Pact tests to ensure they are properly covered also. See docs.pact.io/faq#how-do-i-deal-with-a-situation-where-there-are-multiple-systems-involved-in-a-scenario for more on that.
How do you handle state with this approach? Like, getting the orders depends on the state of the database, i.e. on the database updates that were done previously. Without state, this looks like it's good for type checking only, and I prefer static checks for that.
This is a great question, and is what "Provider States" are designed for. They allow you to setup your system to verify certain API scenarios, without requiring you to coordinate tests to run in a particular order. See docs.pact.io/getting_started/provider_states and our example projects for more.
The pace is good. Easy to understand
Heey nice content, but I'm curious about the Integration + functional strategy is that possible with pact? or do you mean use another tool/test framework for that?
Hi Fatima! Pact is not designed to be used as a general functional testing tool, you would typically use another tool for that purpose.
@@PactFlow What do you consider functional/integration testing in your pyramid? It seems to me like Pactflow does integration tests.
@@zvone187 See this for the difference: docs.pact.io/consumer/contract_tests_not_functional_tests. Pact does a form of integration testing, yes, but it's just about the communication between systems and not focussed on functional tests. The idea is that the combination of better functional tests + contract tests will usually result in a significant reduction in the number of end-to-end tests.
@@PactFlow ah, got it, thanks
Hi This looks great...Do you have a maven example?
We don't that I'm aware of, except for the Pact workshops on our site. Maven is just a build tool however, what's the specific thing you'd like to see?
@@fattymellows Thanks for your response. If possible I would like to see sample Bidirectional demo project built using Maven.
I could not get it at 20:10 So In the provider's contract tests is okay to Hardcode the data to satisface a consumer contract but we need to create another functional test where the provider's handler output is the Hardcode mentioned before?
Yeah weird, right? If the provider response is hardcoded, then it doesn't address the problem which pacts are meant to address - only moves it. You'd need another contract test between the hardcoded response and actual response to have confidence their structure match.
Do you guys can share code for producer and consumer with Kafka and schema registry with avro
We don't have any examples for Avro at this moment. We don't officially support it yet, as discussed in the video. Best to join our slack workspace (slack.pact.io) and ask around there.
@@fattymellows I understand pact doesn't support avro but do we have any workaround to do contract testing with avro schema registry
@@samiksha28071986 not that I'm aware. But somebody else in the community might
my consumer contracts make use of "provider states" - how are these treated in BDCT? my guess it that they are ignored since only the schema is being verified
That's right - provider states are ignored from a BDCT perspective. We are only interested in the sample request/responses to compare against the OAS (provider contract).
If we don't have Postman tests but we do have a swagger file can we upload that and would it still work ? If yes, could you document that ?
Yes, you can do that now. Postman is just one example of a way to test your Provider. The key thing to note is that _you_ must ensure you have some form of testing in place (automated, manual or otherwise) that gives you confidence the API is compliant with the OAS. Pactflow doesn't need this evidence, but we encourage it for hopefully obvious reasons - Matt
I like this. We can just use Cypress instead of Newman as well.
Love BYO, I see a usage when there's no control over 3rd party pipeline.
could you please provide any details about can i deploy service
I'd suggest starting here: docs.pact.io/pact_broker/can_i_deploy
I cloned the GitHub repo, did a npm install then ran the tests - npm t. All I get is - "The pact mock service wasn't running when addInteraction was called"
Hi Andy, best to chat with the team over at slack.pact.io - we'll help you out. Matt
is this repo on github
i am referring to pactflow-example-cpnsumer-java-
All of our example projects can be found here: docs.pactflow.io/docs/examples
thank you!