Is a coherent full stack (client and server) testing strategy possible?
Let’s assume we are doing TDD (and maybe BDD too) and we don’t want to write software without a failing test.
Back in the day, whether you were writing PHP, Java, or Asp.Net, testing your server side application was easy. You wrote unit tests for your models, controllers, data objects, etc. Then, you ran them every few minutes as you wrote new code and features. Everything was simple and all of your tests existed in the same language and execution environment as the business logic (i.e. the server).
JavaScript (i.e. client side business logic) was mostly added using progressive enhancement. This pretty much limited it to page decoration and simple tasks (e.g. date picker, etc). Ajax was also used, but it tended to be somewhat simple. Because of this, not unit testing or not using TDD for progressively enhanced pages didn’t really impact the application much.
After a while, you ended up with 5000-10,000 tests, but it all executed in Java or C#, etc, on the server. Usually, things were really fast. If they weren’t, then that was an issue with the design of the tests, not the technology stack (unless it’s Rails).
Then a movement started to migrate much of the business logic to the browser (e.g. SPA’s). Now, some of the business logic is on the server and some is in the browser. The business logic is spread all over the place (literally) and often there are duplications of logic because the server has to validate and check things that were already checked on the client. All of this logic needs to be unit tested (and maybe BDD too) as it is written, across all levels of the stack. Also, “browser” means actually 4-8 different browsers across, at least, 4-5 (including mobile) operating systems. Obviously, those need to be tested on every run too.
However, there does not seem to be a coherent testing solution that exercises all of the business logic across all of the levels of the technology stack. When I run my unit tests, I need all of my server side tests to be ran. Then, I need all of my client side unit tests to be ran. Then, I need them be be ran for every browser I am targeting across all operating systems. The combinatorial explosion seems daunting and unweildly.
On top of all of that, I also need some sort of post processing to minifiy files, resolve dependencies, and perform a bunch of housekeeping to get the app in a runnable state every time a make a change. Of course, this must occur before the unit tests can be run.
If I can script some solution together that does all of that, it seems to me like it’s going to be slow, complicated, and brittle (if even possible). Once my tests are slow, complicated, and brittle, they aren’t going to be really useful anymore. Frankly, the situation seems like a clusterf***.
This the current environment we do full-stack development in doesn’t seem super robust to me and I am looking for something better.