Is it possible to only run tests that touch changed code in php

63 views Asked by At

I have a testsuite that takes several minutes to complete so it starts to get annoying to run them all before each push (they will still be run in the deployment pipeline as well)

So I was wondering if there are tools that are able to determine which tests are touching the code that was changed.

I found some packages that allow to only run tests for changed files. e.g.:

However these require that the test is specifically for the changed class and do not recursively find dependent code.

So what I am looking for is a solution that would be able to handle this case:

  • Test is for a method on class A.
  • class A method calls a method in class B.
  • I now change the method in class B and the tool should know that the test for class A should be run.

I know that this would not be necessary if class B had it's own test, but this is not the case for my test suite. It mostly comprises of integration tests rather than unit tests.

I only found tools that seem to be able to do it for other languages (e.g. for js): https://wallabyjs.com/

If there is a solution I assume it would need to recursively build a "reverse" dependency tree for each class so it knows all the classes that (in)directly use other classes to be able to identify the affected tests.

Is this a pipedream or does something like this exist for php?

0

There are 0 answers