BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation,...

32
BDD als Ansatz zum Automatisierten Testen von Embedded GUIs und HMIs Embedded Testing 2015 Reginald Stadlbauer

Transcript of BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation,...

Page 1: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

BDD als Ansatz zum Automatisierten Testenvon Embedded GUIs und HMIs

Embedded Testing 2015

Reginald Stadlbauer

Page 2: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

About me

Name: Reginald Stadlbauer Company: froglogic GmbH Position: co-founder and CEO Worked as Software Engineer at Trolltech and the KDE project

Page 3: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

About froglogic

HQ: Hamburg Founded: 2003 US presence since 2008 Product focus on Squish- Squish GUI Tester (Cross-Platform/Cross-Technology GUI Test Automation)- Squish Coco (C, C++ and C# Code Coverage)

More than 3.000 customers world-wide

Page 4: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Overview

What is GUI testing Challenges for cross-platform and embedded Proposed methodology: BDD Live demo

Page 5: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

What is GUI testing

Outside-In Assume user's point of view Automate to spot regressions Combine with profiling, coverage and other analysis and monitoring tools

Page 6: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Why Automate?

Faster- Get results quicker- Run more tests in the same time

Trivial to replay in different configurations Reliable, reproducible and repeatable Relieve testers from monotonous tasks

But...

- Automating GUI tests is not trivial- Typical reason for test effort failures: wrong test approach

Page 7: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Platform Challenge

UIs runs on:

Embedded Linux (several variants) Windows (CE, Embedded, RT) Android iOS QNX VxWorks Nucleus Desktop (Windows, Mac, Linux/Unix) for R&D

Page 8: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Toolkit Challenge

Those play a role:

Native (Android, iOS, ...) Qt QtQuick/QML JavaFx HTML5 ...

Most challenging: combinations of the above.

Page 9: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Platform Solution for Testing

Provided Abstractions by Test Tool

Resolution independence via dedicated UI control support UI abstractions Synchronization methods Distributed environment Reusable functions/objects

Page 10: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Virtualization

Target hardware- the real thing- limited number- harder to automate

Virtual systems- VMware, Virtual Box, qemu- emulator vs. simulator- easy replication, resets and automation- Simulation of hardware features, limitations and events.

Page 11: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Capture and replay

Produces massive test scripts Not readable Not maintainable No code re-use possible Brittle against changes in the UI

Solution: Scripting, Refactoring and Abstractions

Page 12: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Proposed Solution

BDD for test logic and enforcing abstraction Implementation: Specialized UI test driver- Scriptable- Supports used UI controls- Supports remote testing

Page 13: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

What is BDD / BDT?

“BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile methodology. It describes a cycle of interactions with well-defined outputs, resulting in the delivery of working, tested software that matters.” - Dan North

http://en.wikipedia.org/wiki/Behavior-driven_development

OR...

Page 14: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

What is BDD / BDT?

Based on Test Driven Development- Write (failing) test- Implement feature until test passes- Unit-Test level granularity (inside-out)

But- Focus on application's behavior and specification- (Test) Description in a human-readable DSL (Gherkin)- Less focus on implementation details- Clear separation between Tests Logic (Feature Files) and Test Implementation- Allows non-programmers to create tests

Page 15: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Feature Partitioning

Product

Feature A Feature B

Feature C

Feature D Feature E

Page 16: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Components

Features ≠ Units

Feature A Feature B

Feature C

Feature D Feature E

Unit 1

Unit 2

Unit n

Page 17: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Scenarios

Feature A Feature B

Feature C

Feature D Feature E

Scenario D-1Scenario A-1 Scenario E-1

Scenario D-2

Page 18: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Versatile usage of Feature Files

User story / feature specification Communicate with customer / users Documentation of acceptance test Sequence to walk through for manual tests Storyboard for automation of tests

Feature: Aaaaa bbb Scenario: Bbbb ccc Given foo bar zzz And zilch zorro When I do something Then something should

Feature: Aaaaa bbb Scenario: Bbbb ccc Given foo bar zzz And zilch zorro When I do something Then something should

Feature: Aaaaa bbb Scenario: Bbbb ccc Given foo bar zzz And zilch zorro When I do something Then something should

Developer

Tester

Documentation

Customer,Business Owner

Analyst Developer,Tester

Page 19: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Why BDD/BDT

“Test first” development on a higher level Clearly separate test logic from implementation Allow non-programmers to define features & tests Have a common, single language two communicate

Page 20: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Example: Embedded Map App

Page 21: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

A Feature File

Feature: Go to location

Scenario: Navigate to address Given the map application is running When I enter the address Alexanderstr 4, 10178 Berlin, Germany Then the address is found in the district Mitte

Page 22: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

A Feature File (Step types)

Feature: Go to location

Scenario: Navigate to address Given the map application is running When I enter the address Alexanderstr 4, 10178 Berlin, Germany Then the address is found in the district Mitte

PreconditionActionsExpectations

Page 23: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

What is BDD / BDT – The Process

Write a failingFeature Test

MakeFeature Test

pass

Implement/Refactor

Code

Test

Manually Automated

Page 24: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Automating a Behavior Driven Test

Requirements- BDT framework- GUI testing framework- Glue between both

Page 25: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

BDT Framework – Generate Skeletons

Parse feature files Generate step definition skeletons (functions and annotations) in preferred language

Test.feature

Feature: Computation

Scenario: Add two numbers

Given the calc App is running

When I enter 8

....

Test.py

@Step("Given the calc App is running")

def step(context):

test.warning("Implement me”)

@Step("When I enter 8")

def step(context):

test.warning("Implement me”)

Page 26: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

BDT Framework – Run Feature Files

Parse feature files Execute feature files by mapping to steps to step definitions (functions) Reporting

Test.feature

Feature: Computation

Scenario: Add two numbers

Given the calc App is running

When I enter 8

....

Test.py

@Step("Given the calc App is running")

def step(context):

[...]

@Step("When I enter 8")

def step(context):

[...]

Page 27: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Testing framework

Support the specific programming language Support the specific UI technology of AUT Scripting support / integration options Tooling for convenient test creation, maintenance and debugging

Test.py

@Step("Given the calc App is running")

def step(context):

startApplication("calc”)

@Step("When I enter 8")

def step(context):

click("8”)

Page 28: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

BDT Frameworks

Cucumber JBehave Behave SpecFlow RSpec Lettuce Squish GUI Tester ...

Page 29: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

GUI Testing Frameworks

Squish GUI Tester HP QTP Rational Functional Tester Selenium ...

Page 30: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Live Demo – QML Map App

Page 31: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

Q & A

Questions? Email [email protected]

Free and supported trial of Squish at http://www.froglogic.com/evaluate

Page 32: BDD als Ansatz zum Automatisierten Testen von Embedded ...€¦ · “BDD is a second-generation, outside-in, pull-based, multiple-stakeholder, multiple-scale, high-automation, agile

About Squish GUI Tester

Cross-Platform / Cross-GUI-Technology Test Automation- Windows, Linux, Mac OS X, Unix, Embedded, RTOSes, Mobile- Qt/QML/QtQuick, Java (Swing/AWT, SWT/RCP, JavaFx), Web, MFC, WinForms, WPF, iOS, Cocoa, Carbon,

Android, Tk, Flex, …

Object-based GUI object identification Record & replay Powerful scripting (JavaScript, Python, Ruby, Tcl, Perl) Eclipse-based IDE Built-in BDD framework and support

Batch-testing via command-line tools Remote/distributed testing architecture Integrations: Microsoft ALM, HP QC/ALM, Rational RQM, Seapine TCM, SpiraTest, MKS, XStudio,

Jenkins, Hudson, TeamCity, Bamboo, Robot Framework, JUnit, Maven, …