Suite • opensavvy.prepared.suite • TestDsl • immediate
immediate
Realizes a Prepared value from the provided PreparedProvider.
Because the prepared value is created and used immediately, it cannot be saved to be reused—this means that it won't have the reuse behavior of Prepared; that is:
val prepareRandomInt = prepared { random.nextInt() }
val first by prepareRandomInt // bind to a Prepared instance
test("An example") {
assertEquals(first(), first()) // it is bound, so it always gives the same value
assertNotEquals(prepareRandomInt.immediate(), prepareRandomInt.immediate()) // it is unbound, so each call gives a new value
}
This function is mostly useful because test fixtures are often provided as PreparedProvider instance to benefit from the other features of this library. Sometimes, however, we just need a single value at a single point in time, which is why this function exists.