Jeriho Jeriho - 1 year ago 66
Scala Question

How to run specifications sequentially

I want to create few specifications that interoperate with database.

class DocumentSpec extends mutable.Specification with BeforeAfterExample {

def before() = {createDB()}
def after() = {dropDB()}

// examples
// ...

Database is created and dropped before and after every example (which is executed sequentially). Everithing works as expected until there is only one spec that works with database. Because specifications are executed parallel, they interfere and fail.

I hope that I'm able to avoid this by instructing specs2 to run tests with side effects sequentially while keeping side effect free tests to run in parallel. Is it possible?

Answer Source

I suppose you are using SBT? If so, check the documentation:

The relevant SBT setting is parallelExecution. Add this to your project definition:

parallelExecution in Test := false
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download