In my last post I introduced the concept of a Test Persona – a software pattern for building acceptance tests that encapsulate the activities of an indivdual user of the system. I showed that acceptance tests could be refactored so that step definitions are defined in terms of actors in the system, rather than imperative bullet points. In this post, I introduce the pattern of Persona Focussed Testing.
Test Personas can be composed of strategies
Consider using test personas to trigger conversations around the actions and experiences of users that might not be otherwise be easily be apparent when implementing the tests. For instance, we could rewrite the acceptance criteria from the first blog:
Given I am a price-conscious customer When I purchase an item that is sourced from my country Then I will have chosen the 'free delivery' delivery option And I will have paid $0.00 for delivery
The difference here is that we are simulating user behaviour, rather than specifying the appearance or process for purchasing/choosing delivery options.
The implementation in mapping might be rewritten as such:
/I am a price-consious customer/ me = create_customer :item_selection_policy => :cheapest /I purchase an item that is sourced from my country/ my.desired_item = find_item :stock_location => my.location i.purchase_item #### Calling this makes the persona follow a purchase through to completion. /I will have chosen the 'free delivery' delivery option/ my.purchases.last.delivery_option = 'free delivery' /I will have paid $0.00 for delivery/ my.purchases.last.delivery_charge.should.be 0.00
In the above example, the Customer test persona maintains a list of that persona’s own purchases.
Test Personas have agency, and access their own assets
If your Test Personas have email addresses, it might be useful to have the persona provide easy access to the email messages, e.g.: they have received:
my.inbox.should.contain {| msg | msg.subject=="Receipt #${my.purchases.last.receipt_number}" }
The idea here is to only expose access to resources that a given persona has. For instance, I wouldn’t expect a customer to have access to, say, the inventory system, or the shipping manifests. But emails are definitely things a customer would have access to, along with their fax machine, their delivery address, their credit card, etc.
In my next post, I’ll talk about some tentative uses of test personas in defining a good customer experience.
Posted by nickdrew