I’m trying to introduce test groups into an existing code base in order to organize promote testing. The goal is for developers to not focus on what type of test they’re writing, but on when the test is executed. I’d like to use the convention,
-
Fast: tests that are run during the build process (default group)
-
Slow: tests that are typically run only on Jenkins after a commit, e.g. integration testing between a node.js front-end and Java backend servers
-
Daily: tests that are typically run only on Jenkins once per day, e.g. alpha testing against Chrome Dev Channel for detecting incompatibilities
-
???: other groups may be required in the future, e.g. Flaky, but I’d prefer avoiding that. Scenarios like performance regression tests tend to belong outside of a typical xUnit framework.
Using the build-per-branch Jenkins plugin and the Github Commit Status API, each time a developer pushes to their branch a job is triggered. That promotes testing by making it easy to get feedback asynchronously during development and reviewers of a pull request can see the build status before approving.
Currently we have a mix of testing frameworks, each of which have similar groups mechanisms:
-
JUnit for legacy integration tests - categories
-
TestNG for new Java - groups
-
specs2 for Scala - tags
-
qunit tests for node.js - modules (uses the grunt build tool)
-
maybe ScalaTest when helpful (e.g. for the WebDriver DSL) - tags
Naively this seems possible to do using classpath scanning and a group configuration, like the TestNG DSL. However I’m running into a few problems that I haven’t figured out how to resolve: - JUnit doesn’t have a classpath suite runner that supports categories. It looks like the prototype was never released. (should I try to resurrect it?) - Gradle’s JUnit options don’t support categories (Maven’s Surefire plugin does), so not sure how to integrate w/o dedicated suites. - Long term specs2 / ScalaTest support would be nice so that tags are used instead of relying on the JUnit adapters.
I’d prefer not having to separate test groups into different directories or use a naming convention as a work around. Both seem to focus developers on deciding the type of test instead of when their run, which causes more refactoring churn as slow tests become fast (e.g. replacing MySQL with H2) or vice versa.
Is there an integration trick that I’m missing? If not, what is the preferred approach?
Thanks!