Design discussions
As I already pointed out in the previous post, models are great in discussions. Often when you explain the model to the product owner he/she will start noticing quirks. For the example model we developed, one such quirk is that the system is not allowed to reverse a payment if said payment has been involved in a financial application. Although it is a requirement in the system, it was not mentioned in the acceptance criteria because it is not a sun-shine scenario. Design discussions based on models will help you uncover these implicit requirements.It’s easy to solve these quirks when you are at the modeling stage, whereas maintaining traditional scenario based tests can require a lot of effort when requirements change. A benefit from modeling in Agile is that you uncover these implicit requirements early in the development cycle.
In our case we can fix the problem either by adjusting the model to avoid taking the ReversePayment action from states where the payment has been involved in a financial application. But more often than not, we would actually like to have a test case that checks that this implicit requirement is working – that is we would like the model to actually try doing it, but to expect a failure. We update the rule to:
[Rule(Action = "ReversePayment/result")]static bool ReversePayment()
{
Condition.IsTrue(Entries > 0);
if (Applications > 0)
return false;
Entries--;
return true;
}
Two things happen
a) The return value of ReversePayment from the model rule is matched against the return value of the adapter layer when executing tests.
b) The state space will not change if financial applications exist, making the rule a self-looping action.
Our new model looks like:
Tests
Okay, enough design discussions. Let’s look at the actual outcome! Exploring the test case generation we find:Conclusion
Not only does the model serve as a great input to design discussions, it will also automatically produce all your acceptance scenarios. That means when the model adapter layer and the feature you are testing are complete, you simply run your Model-Based test suite as your acceptance criteria.
No comments:
Post a Comment