mobile testing like you mean it- alexandra marin - codemotion milan 2016
TRANSCRIPT
MOBILE TESTING LIKE YOU MEAN IT
MOBILE TESTING LIKE YOU MEAN IT
ALEXANDRA MARIN @ CODEMOTION MILAN 25-26 NOVEMBER 2016
crossplatform.io
Who I am
crossplatform.io
Mobile C# engineerCertified Xamarin developerRemote workerSoftware consultant
But later…public void TestMakingTransfer() {
var amountToPay = 100; var currentAccount = accounts.GetCurrentAccount(); var initialAmount = currentAccount.GetBalance();
currentAccount.Pay(amountToPay);
Assert.AreEqual(initialAmount, payingAccount.Amount - amountToPay); }
crossplatform.io
And now?
crossplatform.io
Feature: Sending out money transfers
A user with a valid account in our app would like to make payments to other users using local or foreign currencies
Scenario 1: I’m sending my friend moneyScenario 2: Paying my Internet bill
crossplatform.io
BEHAVIOR DRIVEN DEVOutside-in Development philosophy in which the application code is written after its requirements have been defined
crossplatform.io
A COLLABORATION TOOLSit down and work together!Conversations tend to uncover assumptions between you and your user’s desired result.
crossplatform.io
PEOPLE CENTRIC APPROACHGet to a common ground by discussing examples and using a language everyone can understand.
Do your future self a favor!
crossplatform.io
RESULTSDocumented features t ied directly to your development and testing process.
Concrete, executable, easy-to-repeat behavior embodied in automated tests.
crossplatform.io
HOW TOInvolve your users!
Everybody contributes in defining specs!
Focus on behavior and specifications!
crossplatform.io
ACCEPTANCE TESTSExecutable specifications written in a domain specific language that describe how a user will interact with the app.
crossplatform.io
ACCEPTANCE TESTSWritten in the language of the business, yet still maintain a connection to your implemented system.
crossplatform.io
Feature: Sending out money transfers
Scenario 1: I’m sending my friend money
Given I have a positive balanceWhen I make a deposit in my friend’s accountThen my account is debitedAnd my friend’s account is credited
crossplatform.io
CUCUMBER & GHERKINGherkin is not a language, but a set of grammar rules!
Cucumber parses and executes the acceptance tests.
crossplatform.io
SPECFLOWCucumber for .NETConverts tests written in plain English (or other language) and into a test fixtureTests follow GIVEN / WHEN / THEN structure
crossplatform.io
THE GOOD- find bugs that unit tests can't such as wiring bugs and environment bugs- tests are described in plain English - ensures the software, as a whole, is feature
complete
crossplatform.io
THE BAD- you’ve moved another level up the testing pyramid- tests touch more code - tracking down a failure can be tricky
crossplatform.io
DO I NEED UI TESTS?Apps have changing requirements that reflect in the UI/UX
Device fragmentation: do you support the specific UI of the app?
It works on my device!
crossplatform.io
WHEN?
Continuous delivery * Repeatable regression
tests * Automation of UI tests * UI development
can drive the application logic * Fixing bugs
crossplatform.io
UI TESTSTest application flows - they’re examples of how you’re actually going to use the app.
crossplatform.io
What can the user see?Simulate UI interactions to provide some example of how your code is valuable to the user (have the rest of the tests at the class level)
crossplatform.io
UI TESTS vs UNIT TESTSMore test coverageDon’t care about system internals
They run on a simulator/emulator or on a physical device
crossplatform.io
CALABASHEnables automatic UI interactions within an application Examples: pressing buttons, entering text, swipe gestures, double tap, pinch to zoom, dismiss keyboard
crossplatform.io
XAMARIN.UITESTAutomated UI Acceptance Testing frameworkValidates functionality of iOS and Android Apps
crossplatform.io
XAMARIN.UITESTWrite C# tests, execute them with NUnit Interact with objects on the screen independent of screen size, orientation and layout
crossplatform.io
XAMARIN.UITESTBuild the AppBundle / APK before running the tests
Add a new NUnit test project
Install Xamarin.UITest from NuGet
crossplatform.io
XAMARIN.UITEST: InternalsThe IApp interface holds an instance of your app which you can interact with
New it up before every test to prevent state from one test affecting the others
crossplatform.io
XAMARIN.UITEST: REPL Interact with a screen while the app is running
Explore the app screens
Creating the queries on the fly
Prototype tests interactively
crossplatform.io
Querying the UILocate view on screen by: id, content description, text, accessibility identifier & label
crossplatform.io
TEST RECORDERThe Test Recorder is available as stand alone application (Mac) or a Visual Studio plugin that records Xamarin.UI tests for you.
crossplatform.io
TEST CLOUDSend the tests to run in the cloud or export a C# file to embed in local Xamarin UITest project.
crossplatform.io
crossplatform.io/ama-xamarin-developer
Questions?
crossplatform.io
Thanks!twitter.com/xmonodev
github.com/alexandra-marincrossplatform.io