lundi 4 mai 2020

Duplication issue on testing a REST API for different versions

It is common to upgrade an API from a version to another (v1 to v2 for example). The new version might offer a couple of new features and probably shares a lot of features with the previous one. In a potential architecture, we can have two controller layers for v1 and v2 while they use the same service layer since they use a lot of shared features.

So, when writing integration tests for v2 there can be two approaches:

  1. Reusing v1's existing tests:
    • making them parameterised to support v2 endpoints when there is no change in the behaviour of an endpoint.
    • Writing new tests for v2 when necessary
    • This will avoid duplication but will introduce a coupling between v1 and v2
  2. Writing a new set of integrations tests for v2:
    • This will involve a lot of copy/paste from v1 to v2 test set but there will be no coupling between the two versions.

Which approach is suitable here?

Aucun commentaire:

Enregistrer un commentaire