-
-
Notifications
You must be signed in to change notification settings - Fork 3
ForgeRule
class ForgeRule : Forge, MethodRule
A JUnit rule to keep your test class clean and automate the creation of fake data.
It provides a Forge with the seed reset on each test, and will inject forgery on fields/properties annotated with Forgery.
In case of failure, the seed of the Forge is printed to the System.err output stream, allowing you to reproduce consistently failing tests.
ruleSeed
- the seed to reset the Forge for each test
ForgeRule(ruleSeed:
Long
= 0L)
A JUnit rule to keep your test class clean and automate the creation of fake data.
It provides a Forge with the seed reset on each test, and will inject forgery on fields/properties annotated with Forgery.
In case of failure, the seed of the Forge is printed to the System.err output stream, allowing you to reproduce consistently failing tests.
ruleSeed
- the seed to reset the Forge for each test
fun apply(base: Statement, method: FrameworkMethod, target:
Any
): Statement
Inheritdoc
fun <reified T :
Any
> withFactory(forgeryFactory: ForgeryFactory<T>):
ForgeRule
Adds a factory to the forge. This is the best way to extend a forge and provides means to create custom forgeries.
T
- the type the ForgeryFactory will be able to forge
forgeryFactory
- the factory to be used
Return the same ForgeRule instance, perfect to chain calls
fun <T :
Any
> withFactory(clazz:
Class
<T>, forgeryFactory: ForgeryFactory<T>):
ForgeRule
Adds a factory to the forge. This is the best way to extend a forge and provides means to create custom forgeries.
T
- the type the ForgeryFactory will be able to forge
clazz
- the class of type T
forgeryFactory
- the factory to be used
Return the same ForgeRule instance, perfect to chain calls
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)