Using Then to organize tests and take screenshots

Xamarin.UITest.Helpers includes a set of methods beginning with Then that:

  1. Make calls to Screenshot implicit.
  2. Help the tester group tests by meaningful sequences of actions, making tests easier to read.
  3. 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.
  4. 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.