TestContainerForAll
Starts a single container before all tests and stops it after all tests
Example:
class MysqlSpec extends FunSuite with TestContainerForAll {
// You need to override `containerDef` with needed container definition
override val containerDef = MySQLContainer.Def()
// To use containers in tests you need to use `withContainers` function
test("test case name") {
withContainers { mysqlContainer =>
// Inside your test body you can do with your container whatever you want to
assert(mysqlContainer.jdbcUrl.nonEmpty)
}
}
}
Notes:
- If you override beforeAll() without calling super.beforeAll() your container won't start
- If you override afterAll() without calling super.afterAll() your container won't stop
trait TestContainersForAll
trait TestContainersSuite
trait DockerImageNameConverters
class Object
trait Matchable
class Any
Suite
Type members
Types
Value members
Concrete methods
Inherited methods
Override, if you want to do something after containers start.
Override, if you want to do something after containers start.
- Inherited from:
- TestContainersSuite
Override, if you want to do something before containers stop.
Override, if you want to do something before containers stop.
- Inherited from:
- TestContainersSuite
To use containers inside your test bodies you need to use withContainers
function:
To use containers inside your test bodies you need to use withContainers
function:
test("test") {
withContainers { mysqlContainer =>
// Inside your test body you can do with your container whatever you want to
assert(mysqlContainer.jdbcUrl.nonEmpty)
}
}
withContainers
also supports multiple containers:
test("test") {
withContainers { case mysqlContainer and pgContainer =>
// test body
}
}
- Value parameters:
- runTest
Test body
- Inherited from:
- TestContainersSuite