Skip to content

Issue calling Setup/Cleanup in tests #2056

Open
@benmccann

Description

@benmccann

Normally you can do some setup and tear down before and after your tests:

testOptions in Test += Tests.Setup( loader => ... )
testOptions in Test += Tests.Cleanup( loader => ... )

Note: When forking, the ClassLoader containing the test classes cannot be provided because it is in another JVM. Only use the () => Unit variants in this case.

So when your tests are forked like Play's you have to do this:

testOptions in Test += Tests.Setup( () => println("Setup") )
testOptions in Test += Tests.Cleanup( () => println("Cleanup") )

I want to start a DB process before my tests run and stop the process after. The issue I'm having is that I don't know how to share a variable between setup and cleanup so that I can take the DB that I started in setup and call the stop method on it in cleanup.

A suggestion would be to have Tests.Setup and Tests.Cleanup replaced by a Tests.Hook which takes a class providing Setup and Cleanup methods. This class could then have member variables shared between the two functions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions