Hi Team, We are trying to use the pactflow bidire...
# pactflow
r
Hi Team, We are trying to use the pactflow bidirection feature and struck on provider side verification result... We don't want to use any other external tool like schemathesis or newman... is it possible to write provider test using xunit (dotnet6) which can also generate the verification result. (provider test similar to whitebox component test, where we start the server inside the test and run test corresponding to it... )
b
Hi @Ravinder Kadiyan, just checking: are you sure you aren't mixing up things here? With bidrectional contract testing, both provider and consumer publish their own version of a contract, which will then be uploaded to Pactflow for comparison. There's no such thing as a 'provider verification result' in BDCT.
Unless you're talking about the part where you can publish additional verification results? That can be 'anything' really, including any report produced by xunit, as far as I know.
As for the actual provider-side contract, I think that still has to be an OpenAPI spec at the moment, but I could be wrong.
r
Usage: pactflow publish-provider-contract CONTRACT_FILE \ --broker-token=BROKER_TOKEN --broker-base-url=BROKER_BASE_URL --provider PROVIDER \ --provider-app-version PROVIDER_APP_VERSION \ --branch BRANCH \ --content-type CONTENT_TYPE \ --verification-exit-code=EXIT_CODE \ --verification-results REPORT_PATH \ --verification-results-content-type REPORT_CONTENT_TYPE \ --verifier VERIFIER I am referring to '--verification-results REPORT_PATH' here.. swagger is still the same way as in bidirection
Instead of using schemathesis or newman, can we write test using xunit at provider side and generate the report..
b
Sure, why not. One typical report to include could be a JUnit XML report for example, see https://xunit.net/docs/format-xml-v2. That'll be written to a file, if you read and base64 encode that, it should work. If you're looking for a library to write those tests, allow me to do a shameless plug for https://github.com/basdijkstra/rest-assured-net
2
m
Of course. We don’t care what tool you use, there are so many good API testing tools - as long as your team is happy using a tool, and are comfortable that your API is well tested
💡 1
r
Thanks @Bas Dijkstra @Matt (pactflow.io / pact-js / pact-go)
a
Is this the right values to provide for xunit as verifier ? @Matt (pactflow.io / pact-js / pact-go) @Bas Dijkstra
Copy code
--content-type application/xml \
--verification-results ./report.xml \
--verification-results-content-type application/xml \
--verifier xunit
Getting an error like "status=400 {"errors":{"verificationResults.success":["is missing"]}}" although the tests are passed.
b
This blog post contains an example where I upload the provider contract via the PactFlow API: https://www.ontestautomation.com/an-introduction-to-contract-testing-part-6-bi-directional-contracts/ (almost at the end of the post). As you can see the verification results contain a success: true entry. You need to specify something similar. PactFlow isn’t going to parse your results file.
Reading https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas I think you need to pass either —verification-exit-code=0 or —verification-success as a flag to resolve that error
m
PactFlow doesn’t know how to interpret the test results, it needs to be told if it’s passing or failing. As Baz said, you need to pass the flag missing in the error
a
Thanks @Matt (pactflow.io / pact-js / pact-go) @Bas Dijkstra. That helped.
🙌 1
API contract test with pactflow now works fine. Now we wanted check with Kafka as well. I could see samples for Java https://github.com/pactflow/example-provider-java-kafka/ Is there any samples in dotnet that we could refer to ? @Matt (pactflow.io / pact-js / pact-go) @Bas Dijkstra
b
I don’t have any, but maybe @Matt (pactflow.io / pact-js / pact-go) or @uglyog does