dimanche 13 août 2017

Is using your API to construct test data for functional testing bad practise?

I'm working on a standard spring boot web app right now, and I've worked on a few in the past as well. In one of my previous projects one of the senior engineers I was working with was using MockMVC to input data into the system as opposed to using the data service layer I was accustomed to on other projects.

Some advantages I saw to this:

  • It constantly tested the API we were building.
  • It validated that the test data we were constructing was actually a possible state to be in.
  • It's easier to map acceptance criteria to code in tests (... AND this user transforms their data... -> 'api/transform')
  • It's easier to call one end point than construct many different entities and persist them.

I've brought this pattern forward to the new project I'm on and wrote a number of functional tests in this fashion, but now this is something I'm being told is bad practise by other developers and there is an item on the backlog to revert to using the data layer. To my knowledge is hasn't caused any issues and a couple of months have gone by since the start of the project where this code was reviewed and accepted, and others were also doing the same (mainly through copying/pasting I imagine).

Is it bad practise to do it this way? I haven't personally hit any issues with it but I'm wondering if there are any pitfalls with it that means it should be avoided.

Aucun commentaire:

Enregistrer un commentaire