On 2013-07-11, at 11:50, Norbert Hartl <norbert@hartl.name> wrote:
I'm playing with Phexampe because I think that in my current project the setup of test scenarios will be a huge part of the testing. So do it in a structured way reducing doubled initialization procedures should be something good. I'm just wondering how the state is kept between dependent test cases. A Phexample test case returns a value so that
value := self given: #shouldHaveCollectedSomeState
transfers the state from the dependent test case into the current. What do you do if the state produced is more complex than a single value?
I don't remember, but calling multiple times #given:, for each part, doesn't solve this problem?
To be honest I don't understand why in a test case that calls #given: a tearDown/setUp cycle is executed between the first and the second test case. I think while using #given: I make the second test case explicitly dependent on the first. Why should I reset state collected by the first before executing the second?
I think that is one of the possible approximations. Since in general you cannot say that a testcase is side-effect free (needs teardown) or has some requirements (setup). On the other hand I would rather expect it not to call the setup, especially in the case where the #given is done on the same class/test suite. I only had a look at phexample a while ago, so I don't remember all the details. I think I will do a try this weekend.