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

Mobile testing for grown ups

Mobile testing for grown ups

NDC London 2017

Alexandra Marin

January 20, 2017
Tweet

More Decks by Alexandra Marin

Other Decks in Programming

Transcript

  1. MOBILE TESTING
    FOR GROWN UPS Alexandra Marin @ NDC London 2017

    View Slide

  2. Hello! I’m a…
    Xamarin Certified Mobile Developer
    Software consultant
    Remote worker
    Cat videos enthusiast
    Gifs also acceptable
    @xmonodev on Twitter

    View Slide

  3. View Slide

  4. BDD

    View Slide

  5. Behavior driven development
    is a philosophy of Outside-in
    Development in which the application
    code is written after its requirements have been
    defined

    View Slide

  6. A COLLABORATION TOOL
    Sit down and work together!
    http://crossplatform.io
    Conversations tend to uncover
    assumptions between you and your
    user’s desired result.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  7. A COLLABORATION TOOL
    Get to a common ground by discussing
    examples and using a language
    everyone can understand.
    http://crossplatform.io
    Do your future self & team a favor!
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  8. RESULTS
    Documented features tied directly to your
    development and testing process.
    Concrete, executable, easy-to-repeat
    behavior embodied in automated tests.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  9. FIND OUT WHAT THE USER WANTS
    Involve your users to ensure that you are
    developing functionality they’re actually
    going to want.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  10. EVERYBODY CONTRIBUTES IN
    DEFINING THE SPECS
    Don’t hand your dev a sheet full of
    predefined requirements.
    Get them together with people from the
    business side.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  11. Focus on behavior and
    specifications
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  12. KEEP IT IMPLEMENTATION FREE
    Don’t worry about the shape of the APIs
    just yet! Focus on behavior and
    specifications instead.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Illustrate business rules with examples (and
    not just the UI)

    View Slide

  13. BDD moves the focus on the
    higher level purposes of the
    system & proving the product.
    (Don’t worry, unit tests still happen,
    but only later in the process)
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  14. ACCEPTANCE TESTING

    View Slide

  15. Acceptance tests are executable
    specifications written in a domain
    specific language that describe how
    a user will interact with the app.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  16. Given [initial context],
    when [event occurs],
    then [ensure some outcomes]
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  17. BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    CUCUMBER & GHERKIN
    Gherkin is not a language, but a
    set of grammar rules!
    Cucumber parses and executes
    the acceptance tests.

    View Slide

  18. Acceptance testing involves writing
    tests to mirror the user stories created
    by and for the software's customer
    during development.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  19. BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Acceptance tests are written in the language of
    the business, all while maintaining a connection to
    your implemented system.
    If the tests pass, it means the software meets the
    customer's requirements and the stories can be
    considered complete.

    View Slide

  20. BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    To see whether the application's functionality satisfies
    the specification, user acceptance testing
    involves performing tests on the full
    system, so make sure to have the
    requirements nailed before you begin
    coding

    View Slide

  21. THE GOOD
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    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

  22. THE BAD
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    you've moved another level up the testing
    pyramid
    tests touch more code
    tracking down a failure can be tricky

    View Slide

  23. UI TESTS

    View Slide

  24. Don’t test small units of logic through the UI.
    Test instead flows - they’re
    examples of how you’re actually
    going to use the app.

    View Slide

  25. UI TESTS: What can the user see?
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    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

  26. WHY DO UI TESTS?
    UI and requirements go hand in hand
    Product is also UX, not just business logic
    Device fragmentation: do you support the specific
    UI of the app?
    It works on my device!
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  27. BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Continuous delivery
    Automation of UI tests
    Repeatable regression tests
    Can drive UI development as well as the
    application logic
    Fixing bugs
    WHEN?

    View Slide

  28. UI TESTS vs UNIT TESTS
    UI tests don’t replace unit test, but round up the test
    coverage
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    They run an iOS / Android application on a simulator/
    emulator or on a physical device
    Use an environment that is closest to production
    Don’t care about system internals

    View Slide

  29. THE TOOLS

    View Slide

  30. SPECFLOW
    Cucumber for .NET
    Converts tests written in plain English (or
    other language) and into a test fixture
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Tests follow GIVEN / WHEN / THEN
    structure

    View Slide

  31. XAMARIN UITEST
    Based on Calabash
    Validates functionality of iOS and Android
    Apps
    Automated UI Acceptance Testing
    framework
    Enables interactions within an application
    Examples: pressing buttons, entering text,
    swipe gestures
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  32. XAMARIN.UITEST
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Write C# tests, execute them with NUnit
    Interact with objects on the screen independent of
    screen size, orientation and layout

    View Slide

  33. XAMARIN.UITEST: Setup
    Build the AppBundle / APK before running the
    tests
    Add a new NUnit test project
    Install Xamarin.UITest from NuGet
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  34. 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
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  35. 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
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  36. XAMARIN.UITEST: Querying the UI
    Locate view on screen by: id, content description, text,
    accessibility identifier & label
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS
    Func
    Example: x => x.Class(“UITextField”)

    View Slide

  37. TEST RECORDER & TEST CLOUD
    The Test Recorder is available as stand alone
    application (Mac) or a Visual Studio plugin that records
    Xamarin.UI tests for you.
    It can send the tests to run in the cloud or export a C#
    file to embed in local Xamarin UITest project.
    BDD
    ACCEPTANCE TESTING
    UI TESTING
    THE TOOLS

    View Slide

  38. Ask Me
    Anything
    crossplatform.io/ama-xamarin-developer | @xmonodev

    View Slide

  39. @xmonodev
    http:/
    /crossplatform.io
    Thanks! :)

    View Slide