Hello! My organization is looking at adopting cont...
# pact-ruby
p
Hello! My organization is looking at adopting contract testing. We have a very large existing suite of integration tests that use VCR. Has anyone actually succesfully converted VCR cassettes into consumer contracts, and/or built any utility to do so? https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/pact/#converting-mocks-into-a-pact-compatible-format
Tools like VCR and Polly can record the actualy calls your application makes and story them as a fixture file for future use. This makes your tests reliable, but introduces the possibility of drift. Converting this mocks into a pact file reduces that possibility.
c
You'd have to write the contract tests. VCR is similar, you could probably meta-program it but I wouldn't. I would just do one or two and see how it goes. I tried Polly a long time ago (because I missed VCR) and didn't have a great time. Also, VCR is more like a magic mock. Pact is sort of a different type of testing tool. A typical CI flow (to me would be something like this) • unit tests (which ideally would not need VCR) • integration tests (which could use VCR for conveniences) • contract tests (which are trying to enforce many-service interactions) Theses are different levels and styles usually using different libraries. • unit tests (rspec) • integration tests (maybe rspec's request specs, but now you need bigger libraries) • contract tests (pact) I know some Ruby apps are all mixed up (take Rails) where there are not clean lines between the things. But you'll probably find yourself over time on a project not running the end-to-end tests that much and now you've filtered the tests for productivity. And you'd do the same in a CI pipeline where each test step is fancier and fancier. Essentially, the testing pyramid. • It tells you what to write • It also kind of tells you what order your tests should run in (pact is beyond the peak)
🙌 1
parrot2 1