Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mobile testing like you mean it

Mobile testing like you mean it

Alexandra Marin

November 26, 2016
Tweet

More Decks by Alexandra Marin

Other Decks in Programming

Transcript

  1. MOBILE TESTING LIKE YOU
    MEAN IT
    MOBILE TESTING LIKE
    YOU MEAN IT
    ALEXANDRA MARIN @ CODEMOTION MILAN 25-26 NOVEMBER 2016
    crossplatform.io

    View Slide

  2. Who I am
    crossplatform.io
    Mobile C# engineer
    Certified Xamarin developer
    Remote worker
    Software consultant

    View Slide

  3. At first…
    // TO DO
    // Needs testing
    crossplatform.io

    View Slide

  4. 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

    View Slide

  5. 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 money
    Scenario 2: Paying my Internet bill

    View Slide

  6. crossplatform.io
    BEHAVIOR DRIVEN DEV
    Outside-in Development philosophy in
    which the application code is written
    after its requirements have been defined

    View Slide

  7. crossplatform.io
    A COLLABORATION TOOL
    Sit down and work together!
    Conversations tend to uncover
    assumptions between you and your
    user’s desired result.

    View Slide

  8. crossplatform.io
    PEOPLE CENTRIC APPROACH
    Get to a common ground by discussing
    examples and using a language
    everyone can understand.
    Do your future self a favor!

    View Slide

  9. crossplatform.io
    RESULTS
    Documented features tied directly to your
    development and testing process.
    Concrete, executable, easy-to-repeat behavior
    embodied in automated tests.

    View Slide

  10. crossplatform.io
    HOW TO
    Involve your users!
    Everybody contributes in defining specs!
    Focus on behavior and specifications!

    View Slide

  11. crossplatform.io
    ACCEPTANCE TESTS
    Executable specifications written in a
    domain specific language that describe
    how a user will interact with the app.

    View Slide

  12. crossplatform.io
    ACCEPTANCE TESTS
    Written in the language of the business,
    yet still maintain a connection to your
    implemented system.

    View Slide

  13. crossplatform.io
    Feature: Sending out money transfers
    Scenario 1: I’m sending my friend money
    Given I have a positive balance
    When I make a deposit in my friend’s account
    Then my account is debited
    And my friend’s account is credited

    View Slide

  14. crossplatform.io
    CUCUMBER & GHERKIN
    Gherkin is not a language, but a set of grammar
    rules!
    Cucumber parses and executes the acceptance
    tests.

    View Slide

  15. crossplatform.io
    SPECFLOW
    Cucumber for .NET
    Converts tests written in plain English (or other
    language) and into a test fixture
    Tests follow GIVEN / WHEN / THEN structure

    View Slide

  16. 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

    View Slide

  17. crossplatform.io
    THE BAD
    - you’ve moved another level up the
    testing pyramid
    - tests touch more code
    - tracking down a failure can be tricky

    View Slide

  18. 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!

    View Slide

  19. crossplatform.io
    WHEN?
    Continuous delivery * Repeatable regression
    tests * Automation of UI tests * UI development
    can drive the application logic * Fixing bugs

    View Slide

  20. crossplatform.io
    UI TESTS
    Test application flows - they’re
    examples of how you’re
    actually going to use the app.

    View Slide

  21. 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)

    View Slide

  22. crossplatform.io
    UI TESTS vs UNIT TESTS
    More test coverage
    Don’t care about system internals
    They run on a simulator/emulator or on
    a physical device

    View Slide

  23. crossplatform.io
    CALABASH
    Enables automatic UI interactions within
    an application
    Examples: pressing buttons, entering text, swipe
    gestures, double tap, pinch to zoom, dismiss
    keyboard

    View Slide

  24. crossplatform.io
    XAMARIN.UITEST
    Automated UI Acceptance Testing
    framework
    Validates functionality of iOS and
    Android Apps

    View Slide

  25. crossplatform.io
    XAMARIN.UITEST
    Write C# tests, execute them with NUnit
    Interact with objects on the screen
    independent of screen size, orientation
    and layout

    View Slide

  26. crossplatform.io
    XAMARIN.UITEST
    Build the AppBundle / APK before
    running the tests
    Add a new NUnit test project
    Install Xamarin.UITest from NuGet

    View Slide

  27. crossplatform.io
    XAMARIN.UITEST: Internals
    The 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

    View Slide

  28. 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

    View Slide

  29. crossplatform.io
    Querying the UI
    Locate view on screen by: id, content
    description, text, accessibility identifier &
    label

    View Slide

  30. crossplatform.io
    TEST RECORDER
    The Test Recorder is available as stand
    alone application (Mac) or a Visual
    Studio plugin that records Xamarin.UI
    tests for you.

    View Slide

  31. crossplatform.io
    TEST CLOUD
    Send the tests to run in the cloud or
    export a C# file to embed in local
    Xamarin UITest project.

    View Slide

  32. crossplatform.io
    crossplatform.io/ama-xamarin-developer
    Questions?

    View Slide

  33. crossplatform.io
    Thanks!
    twitter.com/xmonodev
    github.com/alexandra-marin
    crossplatform.io

    View Slide