During the past several years, my company has gone from running a handful of automated tests on a single server to running thousands of automated tests. These include unit tests, integration tests and Selenium tests. The Selenium tests are particularly slow, and although we can parallelize them, the builds still take upwards of an hour to run. We typically don’t run the full regression build on every push, but instead use them to validate code prior to merging a branch to master and tagging.
We’ve come up with our own workflow and hodge-podge of tools to generate test analytics, but we’re looking a tool or product that we could integrate into our build system to streamline the workflow and give us insight into identifying slow and intermittently failing tests (typically due to Selenium stability). We’re currently using Jenkins and CircleCI (different projects).
What options are out there? Have other developers encountered challenges managing their automated tests infrastructure? Have you developed in-house tools to address this? Or are there any software tools that you’d recommend?
Unfortunately there is no silver bullet to make your tests run faster. I have used both Jenkins and CircleCI and they are great for most environments.
To combat this speed issue I have added a timer to all of my individual test runs. In Ruby with rspec, for example, this is relatively simple by just adding --profile to your .rspec file. Every time your test suite is run, this will show the top 10 slowest running tests. Each testing framework has a similar mechanism or add-on which will give you a report. Next start refactoring those long running tests. At first it will seem like a slow processes, but working on it a bit each day will quickly show significant improvement in your testing suite speed.
Next, watch out for tests, particularly integration tests and Selenium tests, which either test the framework and not your code, or which are redundant. A number of times I have walked into clients offices and have been told that their test suite is as "tight as it can be" and yet still runs slow. I look through it and find many areas where engineers in their desire to test thoroughly were unfortunately testing areas they don't need to. A bit of refactoring again showed massive dividends.
Finally, don't be afraid to segment your tests to run only portions that are effected by the code that was changed. It's true that running the entire suite is important, but you're correct in only running the whole thing at certain times. My current project has segments for API, various Front End resources, and service integrations. There are a number of sub segments as well. Again I think of this as a test refactoring exercise, but it will pay off if designed well.
So, unfortunately I don't have a software solution that will solve your problems. But I can say that a few refactoring activities can make all of the difference.