I have a bunch of scalatest classes that are all based on FlatSpec. I run all my tests in parallel using the -P command line parameter of scalatest. This works fine except for a few of the test classes which depend on some global variable. To make these tests reliable, I have to avoid running them in parallel.
Is there a way to flag a given test as "please don't ever try to run these tests in parallel to any other tests"?
So, just to make it clear:
- given I have 10 test classes where 2 of them are not parallel-frendly
- I want to run the 2 tests classes sequentially
- all tests from the other 8 classes should be executed in parallel
- all these 10 tests must be executed through a single invocation of the scalatest runner so that I can run all my tests using a single run configuration in IntelliJ.
I am therefore looking for something like the [CollectionDefinition(DisableParallelization = true)] attribute that xunit offers.
You can have Custom test configuration. That will let you have different setup for each test configuration. One for the test that can be executed in parallel and another one for the ones that you need to run sequentially. Remember that sbt run all task in parallel by default. So, for each config you can have different setups.
having a directory structure like
and your
build.sbtwill be something like