0

Trying to test a simple feature which is contained in a very complex feature.

The simple feature requires multiple steps before it can be launched. These steps have many consequences on the database, but they don't have any interaction with the feature itself.

Since we'd like to test this simple feature only through our API, one of the idea was to create a route dedicated to testing this. We'd then do a cron visiting that route once in a while, testing whether or not the feature still works.

I find it kinda disturbing to have one or many route(s) existing only for the sole purpose of testing. But I can see the advantages which are numerous.

Is that good practice or is there a better way to do it ?

Steve Chamaillard
  • 2,289
  • 17
  • 32

1 Answers1

1

It is hard to answer a question with such level of abstraction, as you could be describing anything. But in a nutshell, if accessing feature itself is complicated, so will be the test.

Integration testing is the phase of software testing in which individual software modules are combined and tested as a group.

I think you are a bit mistaken saying your features don't rely on each other. If there is a number of steps which are mandatory, it indicates there is a connection between the two. You should either tests them together as suggested in the quote above or decouple your features so they could be truly standalone.

As an example, one can have post news feature which requires authentication and authorization. There are some helpers build in to ease such tests in Laravel itself. If this example is similar enough to your problem, far better solution would be to write such helper than creating cron job for it. With a cron job, you'd need to replicate the same thing in every environment you have, and all developers environments as well.

lchachurski
  • 1,770
  • 16
  • 21