-
-
Notifications
You must be signed in to change notification settings - Fork 3
Spek
Xavier Gouchet edited this page Aug 24, 2020
·
1 revision
The spek
module provides integration with the Spek Test Framework.
When writing a Spek test, you can create a root Forge
instance, that will allow you to forge random test inputs.
class FooSpek : Spek({
val forge = spekForge()
// …
})
Whenever a test fails, or just to reproduce the same test exactly, you can use the spekForge
's seeds
parameter.
Seeds will be assigned based on the qualified name of a test or group.
class FooSpek : Spek({
val forge = spekForge(
seeds = mapOf(
"FooSpek/Foo feature/bar/baz" to 0x1337L
)
)
describe("Foo feature") {
describe("bar") {
it("baz") {
val i = forge.anInt()
// …
}
}
}
})
Chances are, you'll need to forge more than primitives or Strings. To do so you'll need to use Factories.
A simple way to provide that to the extension is to use the spekForge
's seeds
parameter with a custom configurator instance.
class FooSpek : Spek({
val forge = spekForge(
configurator = MyConfigurator()
)
// …
})
class MyConfigurator : ForgeConfigurator {
override fun configure(forge: Forge) {
forge.addFactory(Foo::class.java, FooFactory())
forge.addFactory(Bar::class.java, BarFactory())
}
}
Xavier F. Gouchet – @xgouchet
Distributed under the MIT license. See LICENSE.md for more information.
https://github.com/xgouchet/Elymr
- Home
- Getting Started
- Core Module
- Integrations
- Reference (core)
- Reference (junit4)
- Reference (junit5)
- Reference (spek)