mardi 23 avril 2019

Consumer Driven Contract Tests for C++ APIs

I am developing a static C++ library that has some Public APIs. I have to implement Consumer Driven Contract for the APIs that the library provides. But in my case I have to provide the contract to the consumers on which they will agree upon.

The inspiration of implementing the Contract based testing came from PACT (https://docs.pact.io/). The contract in PACT is in form of JSON file and it is mainly based on REST and http responses.

If I have to implement the contract based testing for C++ APIs. Then what is the best approach. I could see boost has Design By Contract, but it is more like Assertions but there is contract define in a file like PACT. (https://www.boost.org/doc/libs/develop/libs/contract/doc/html/index.html)

Is there any way that the contract can be defined in a file and all the APIs can be tested. The main purpose of this is to test in isolation.

Could you please share some inputs on to implement the contracts defined in a file and write a test program for these contracts.

Aucun commentaire:

Enregistrer un commentaire