Using Then to organize tests and take screenshots
Xamarin.UITest.Helpers includes a set of methods beginning with Then that:
- Make calls to
Screenshotimplicit. - Help the tester group tests by meaningful sequences of actions, making tests easier to read.
- Resolve the apparent contradiction betweeen source chronology and screenshot labels by allowing the developer to write the label before the actions, but still performing actions before taking the screenshot.
- In practice, I've found that I take many more screenshots when using implicit screenshotting, resulting in much nicer, much more fine-grained reports in Xamarin Test Cloud.
Examples:
Then("I tap 'Log In'", () => {
Button["Log In"].Tap();
});
// Equivalently:
Then("I tap 'Log In'", () => Button["Log In"].Tap());
// Without using a lambda:
Then("I tap 'Log In'", Button["Log In"].Tap);
// Or just keep it simple:
ThenTap("Log In");
The remaining Then* methods suggest a convention: Then* prefixed methods generate screenshots.