Is it possible to parameterize a Spock setup
?
By that I mean, imagine I have an object whose state I want to test. The object can have multiple states, but to simplify things, let's say there's one I'm particularly interested in, S1
.
There are multiple ways to get the object to S1
. I'm testing state, so all the tests for S1
will be the same regardless of how the object reached S1
. The one thing that would differ between test cases would be the setup
strategy.
One way to deal with this is to have a base test case (or "spec" to use Spock parlance) and subclasses that only supply different setup
strategies.
But, given the nice data-driven features of tests that Spock offers, I got to wondering if there might be some way to parameterize the setup in such a way that I wouldn't need concrete subclass specs.
In effect, I would be saying, here's a spec, now run it with these different ways of executing setup.
Aucun commentaire:
Enregistrer un commentaire