How does `memoized` work? I have something like th...
# spek
d
How does
memoized
work? I have something like this:
Copy code
class Test : Spek {
     val something by memoized { mockk<ISomething>() }

    given("do this") {
         every { something.doThis() } returns true

        on("that happened") {
               it("verify") {
.....
}
The something doesn't have the value true I gave it on
given
... I tried using other caching strategies, but natta...
r
wrap
every
in a
beforeEachTest
. I'm suspecting
every
is being invoked during the discovery phase.
d
Thanks, that helped! But I'm wondering why in
on
I also put
every
w/o
beforeEachTest
(it's deprecated?) and it works,
group
is different than
on
@raniejade?
r
on
is an
action
, which is basically a
test
that can contain other
test
. The difference of
group
and
action
is when they are invoked .
group
is invoked during discovery phase to build the test tree, while
action
is only invoked during the execution phase.
I'm rewriting the docs to explain more better how spek's scopes work.
d
Thanks for the explanation 🙂 , docs in this area would be great! I spent a while trying to understand all this from other's examples, and still got stuck... I think everyone would benefit from proper docs, thanks for all the time you're putting into this!
Also, it might be nice to know how to factor out pieces of test code that just clutters the test for nothing... I don't know if there's anything to do about
memoized
properties that depend on others and each one has its mocks and is dependent on others.. it can get hard to see the actual tests... @raniejade
r
can you give an example?