eine einführung in das automatisierte testen mit dem robot...

76
aformatik Training & Consulting GmbH & Co. KG 1 Eine Einführung in das automatisierte Testen mit dem Robot-Framework Thomas Gauss aformatik Training & Consulting GmbH & Co. KG

Upload: vanlien

Post on 07-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 1

Eine Einführung in das automatisierte Testen

mit dem Robot-Framework

Thomas Gauss

aformatik Training & Consulting GmbH & Co. KG

Page 2: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 2

Fahrplan – Agenda

Page 3: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 3

Vorstellung des Robot-Frameworks

Framework zur (automatischen) Durchführung von Akzeptanztests

Keyword-Driven Testing

generisch, modular und erweiterbar

in aktiver Entwicklung (seit 2005)

frei verfügbar

umfangreich dokumentiert

Page 4: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 4

Einsatzzweck

Unit-

test

Integrations-

test

System-

test

Akzeptanz-

test

Page 5: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 5

Einsatzzweck

Unit-

test

Integrations-

test

System-

test

Akzeptanz-

test

Page 6: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 6

Test-Framework - Typen

System under Test

Framework

Linear

Daten und Ablauf

System under Test

Framework

System under Test

Framework

Data-driven

Ablauf

Daten

Keyword-driven

AblaufDaten

Page 7: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 7

Test-Framework - Typen

System under Test

Framework

Linear

Daten und Ablauf

System under Test

Framework

Data-driven

Ablauf

Daten

Keyword-driven

AblaufDaten

System under Test

Framework

Page 8: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 8

Keyword-Driven Testing

Beschreibung eines Tests durch verständliche Anweisungen („Keywords“)

Tatsächliche (technische) Durchführung des Tests wird vom Framework übernommen

Beispiel:

Launch Application de.aformatik.jsf2015.SampleAppStarter

Select Main WindowPush Button Ändere TitelSelect Dialog Titel-EingabeInsert Into TextField OptionPane.textField Herzlich willkommen beim...Push Button OK

Select Main WindowPush Button Wähle BildChoose From File Chooser jfslogo.jpg

Page 9: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 9

Testablauf

Robotframework

Daten

&

Ablauf

„Input“

Page 10: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 10

Testablauf

Robotframework

Daten

&

Ablauf

„Input“

Page 11: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 11

Testablauf

Robotframework

Daten

&

Ablauf

„Input“

Protokoll

„Output“

Page 12: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 12

Test-Protokoll

Page 13: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 13

Test-Protokoll

Page 14: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 14

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Page 15: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 15

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Page 16: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 16

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Python

(C)Python

Page 17: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 17

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Python

(C)Python PyPy

Page 18: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 18

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Python

(C)Python PyPy Jython

Java

Page 19: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 19

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Python

(C)Python PyPy Jython

Java

JVM

Page 20: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 20

Framework-Stack

Robotframework

Daten

&

Ablauf

Protokoll

Keyword-Bibliotheken

Python

(C)Python PyPy Jython

Java

JVM

Page 21: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 21

„Generisch, modular und erweiterbar“

Framework kommuniziert über „Benutzerschnittstelle“ mit dem zu testenden Programm

(SUT – „System under Test“)

Trennung von Test-Beschreibung, -Implementierung und -Daten

Ergebnisausgabe auch als xml (für automat. Weiterverarbeitung)

Eigene Bibliotheken einbindbar

Framework ist freie Software

Page 22: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 22

Entwicklung

seit 2005, Master-Arbeit von Pekka Klärck (geb. Laukkanen)

Entwicklung wird unterstützt durch Nokia (Siemens) Networks

Freie Software (Apache 2.0 Lizenz)

Verteilt auf eigene Webseite, Github und (früher) Google Code

Teilprojekte teils ausgelagert, teils eingegliedert

Sprache: Python

Umfangreiche Dokumentation zum Framework

Page 23: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 23

Dokumentation zu Keywords („Libdoc“)

Automatische Dokumentation der Keyword-Bibliotheken, ähnlich zu Javadoc

Page 24: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 24

Fahrplan – Agenda

Page 25: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 25

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 26: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 26

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 27: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 27

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 28: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 28

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 29: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 29

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 30: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 30

Testdaten-Aufbau

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 31: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 31

Testdaten-Aufbau

Testsuite

(Text-Cases-Datei)

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

Page 32: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 32

Testdaten-Aufbau

Testsuite

(Text-Cases-Datei)

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello2.robot

Page 33: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 33

Testsuite

(Text-Cases-Datei)

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello2.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello3.robot

Testdaten-Aufbau

Page 34: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 34

Testdaten-Aufbau

Testsuite

(Text-Cases-Datei)

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello2.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello3.robot

Testsuite

Page 35: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 35

Eingabeformat

„Tabellenartig“

Verschiedene Eingabeformate:

HTML

tab-separated values (TSV)

plain text (mit Doppel-Leerzeichen oder Pipe); .robot, .txt

reStructuredText (reST)

Testfall Eins

Log Hallo Welt!

Page 36: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 36

Eingabeformat

„Tabellenartig“

Verschiedene Eingabeformate:

HTML

tab-separated values (TSV)

plain text (mit Doppel-Leerzeichen oder Pipe); .robot, .txt

reStructuredText (reST)

Testfall Eins

Log Hallo Welt!

Testfall EinsLog Hallo Welt!

Page 37: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 37

Eingabeformat

„Tabellenartig“

Verschiedene Eingabeformate:

HTML

tab-separated values (TSV)

plain text (mit Doppel-Leerzeichen oder Pipe); .robot, .txt

reStructuredText (reST)

Testfall Eins

Log Hallo Welt!

Testfall EinsLog Hallo Welt!

Page 38: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 38

Eingabeformat

„Tabellenartig“

Verschiedene Eingabeformate:

HTML

tab-separated values (TSV)

plain text (mit Doppel-Leerzeichen oder Pipe); .robot, .txt

reStructuredText (reST)

Testfall Eins

Log Hallo Welt!

Testfall EinsLog Hallo Welt!

Page 39: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 39

Eingabeformat

„Tabellenartig“

Verschiedene Eingabeformate:

HTML

tab-separated values (TSV)

plain text (mit Doppel-Leerzeichen oder Pipe); .robot, .txt

reStructuredText (reST)

Testfall Eins

Log Hallo Welt!

Testfall EinsLog Hallo Welt!

}Einfache und

laxe Syntax

(„semicolon free“)

Page 40: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 40

Keywords

Framework stellt grundlegende Keywords bereit

(z.B. „Log“, „Should Be Equal“, …)

Framework liefert zudem Keyword-Bibliotheken, z.B. für

Swing, Selenium(2) (Browserschnittstelle für Webanwendungen)

Datenbank-Zugriff

Telnet, HTTP, SSH,…

Screenshots, Betriebssystemzugriff, Benutzereingaben

Android, IOS

Zusammenfassung von Keywords zu einem neuen Keyword

selbstdefinierte Keywords (mit Python oder Java)

Keyword wirft Exception, falls Test fehlschlägt

Page 41: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 41

Beispiel (1)

*** Settings ***Library SwingLibraryLibrary Screenshot

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep 3 seconds

Select Main WindowPush Button Ändere TitelSleep 3 seconds

Select Dialog Titel-EingabeInsert Into TextField OptionPane.textField Herzlich willkommen beim...Sleep 3 seconds

Take Screenshotwelcome-jfs.robot

Page 42: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 42

Beispiel (1)

*** Settings ***Library SwingLibraryLibrary Screenshot

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep 3 seconds

Select Main WindowPush Button Ändere TitelSleep 3 seconds

Select Dialog Titel-EingabeInsert Into TextField OptionPane.textField Herzlich willkommen beim...Sleep 3 seconds

Take Screenshotwelcome-jfs.robot

Page 43: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 43

Beispiel (2)

*** Settings ***

*** Test Cases ***

*** Keywords ***Wähle Titel

[Arguments] ${titel} [Documentation] Wählt einen Titel aus.Push Button Ändere TitelSleep 3 seconds

Select Dialog Titel-EingabeInsert Into TextField OptionPane.textField ${titel}Sleep 3 seconds

Push Button OKSleep 3 seconds

welcome-jfs.robot

……

Page 44: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 44

Beispiel (2)

*** Settings ***

*** Test Cases ***

*** Keywords ***Wähle Titel

[Arguments] ${titel}[Documentation] Wählt einen Titel aus.Push Button Ändere TitelSleep 3 seconds

Select Dialog Titel-EingabeInsert Into TextField OptionPane.textField ${titel}Sleep 3 seconds

Push Button OKSleep 3 seconds

welcome-jfs.robot

……

Page 45: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 45

Beispiel (2)

*** Settings ***

*** Test Cases ***

*** Keywords ***Wähle Titel

Wähle Bild[Arguments] ${dateiname}Push Button Wähle BildSleep 3 secondsChoose From File Chooser ${dateiname}

welcome-jfs.robot

……

Page 46: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 46

Beispiel (2)

*** Settings ***Library SwingLibraryLibrary Screenshot

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep 3 seconds

Select Main WindowWähle Titel Herzlich willkommen beim...

Select Main WindowWähle Bild jfslogo.jpg

Take Screenshot

welcome-jfs.robot

Page 47: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 47

Beispiel (3)

*** Keywords ***Wähle Titel

[Arguments] ${titel}[Documentation] Wählt einen Titel aus.Push Button Ändere Titel

Titel muss "${titel}" sein[Documentation] Überprüft den Titel.${actual_title}= Get Selected Window TitleShould Be Equal ${titel} ${actual_title}

welcome-jfs.robot

Page 48: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 48

Beispiel (3)

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep 3 seconds

Select Main WindowWähle Titel Herzlich willkommen beim...

Select Main WindowTitel muss "Herzlich willkommen beim..." sein

Select Main WindowWähle Bild jfslogo.jpg

Take Screenshot…

welcome-jfs.robot

Page 49: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 49

Beispiel (4)

*** Settings ***Library SwingLibraryLibrary Screenshot

*** Variables ***${DELAY}= 3 seconds

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep 3 seconds

Select Main Window

welcome-jfs.robot

Page 50: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 50

Beispiel (4)

*** Settings ***Library SwingLibraryLibrary Screenshot

*** Variables ***${DELAY}= 3 seconds

*** Test Cases ***JFS-Demo-Test

Launch Application de.aformatik.jsf2015.SampleAppStarterSleep ${DELAY}

Select Main Window

welcome-jfs.robot

Page 51: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 51

Fahrplan – Agenda

Page 52: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 52

Aufbau einer Test-Cases-Datei

*** Settings ***

*** Variables ***

*** Test Cases ***

*** Keywords ***

welcome-jfs.robot

……

……

Page 53: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 53

Testdaten-Aufbau - Revisited

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello2.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

hello3.robot

Testsuite

Page 54: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 54

Testdaten-Aufbau - Revisited

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

01__hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

02__hello2.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

03__hello3.robot

Testsuite

Page 55: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 55

Testdaten-Aufbau - Revisited

*** Test Cases ***Testfall Eins

Log Hallo Welt!Log Noch mehr Text...

Testfall ZweiLog Und noch mehr Text...Log und Schluss!

01__hello_world.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

02__hello2.robot

*** Test Cases ***Noch ein Testfall

Log Hallo Welt!...

03__hello3.robot

Testsuite

*** Settings ***Suite Setup …Suite Teardown …

__init__.robot

Page 56: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 56

Syntax-Besonderheiten

Keywords (und Variablen, etc.) sind case-insensitive und

(einzelne) Spaces and Underscores werden ignoriert:

Beim Aufruf eines Keywords können „Given”, „When“, „Then“, „And“ und „But“

hinzugefügt werden (ohne Auswirkung).

(Ermöglicht „Behavior Driven Development“-Stil)

Mehr als 2 Leerzeichen werden wie zwei Leerzeichen behandelt

Zeilenumbruch:

Wähle Titel Herzlich willkommen beim...

wäH le_ti_tel Herzlich willkommen beim...

Wähle Titel... Herzlich willkommen beim...

Page 57: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 57

SwingLibrary

Es muß zuerst ein Kontext festgelegt werden:

z.B. ,

In diesem Kontextes werden Komponenten identifiziert durch

ihren Index im Container (nicht zu empfehlen),

ihren Namen,

ihre Beschriftung (falls vorhanden, z.B. bei Buttons).

Hilfsmittel:

JSpy

Ctrl+Shift+F1 (Swing)

Als Kontext dürfen leider nur bestimmte Container dienen:

Select Dialog Titel-EingabeSelect Main Window

List Components in Context

Page 58: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 58

Entwicklungsumgebung

RIDE („Robot-IDE“)

Plugin/Syntax-Highlighting für

Eclipse,

Notepad++, Vim, Emacs, …

Page 59: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 59

Fahrplan – Agenda

Page 60: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 60

Beispiel (1)

*** Settings ***Library de.aformatik.robotlib.MyRobotLibrary

welcome-jfs.robot

Page 61: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 61

Beispiel (1)

*** Settings ***Library de.aformatik.robotlib.MyRobotLibrary

welcome-jfs.robot

public class MyRobotLibrary extends AnnotationLibrary {public MyRobotLibrary() {super(Arrays.asList("de/aformatik/robotlib/kw/*"));

}}

MyRobotLibrary.java

Page 62: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 62

Beispiel (1)

*** Settings ***Library de.aformatik.robotlib.MyRobotLibrary

welcome-jfs.robot

public class MyRobotLibrary extends AnnotationLibrary {public MyRobotLibrary() {super(Arrays.asList("de/aformatik/robotlib/kw/*"));

}}

MyRobotLibrary.java

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

…de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 63: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 63

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

Beispiel (1)

…de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 64: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 64

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

Beispiel (1)

…de/aformatik/robotlib/kw/TreeTableKeywords.java

*** Test Cases ***JFS-Demo-Test

Expand My TreeTable Node Historie|Herzlich willkommen beim...

welcome-jfs.robot

Page 65: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 65

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

System.out.println("*INFO* " + "expandMyTreeTableNode: " + nodeIdentifier);

ContainerOperator mainframe = (ContainerOperator) Context.getContext();

JRootPane rootPane = (JRootPane) mainframe.getComponent(0);JLayeredPane layeredPane = (JLayeredPane) rootPane.getComponent(1);JPanel contentPane = (JPanel) layeredPane.getComponent(0);JScrollPane scrollPane = (JScrollPane) contentPane.getComponent(0);JViewport viewport = (JViewport) scrollPane.getComponent(0);JXTreeTable treetable = (JXTreeTable) viewport.getComponent(0);JTree theTree = (JTree) treetable.getCellRenderer(0, 0);

Beispiel (1)

…de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 66: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 66

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

System.out.println("*INFO* " + "expandMyTreeTableNode: " + nodeIdentifier);

ContainerOperator mainframe = (ContainerOperator) Context.getContext();

JTree theTree = (JTree) treetable.getCellRenderer(0, 0);

JTreeOperator jemmyOperator = new JTreeOperator(theTree);TreeOperator robotOperator = new TreeOperator(jemmyOperator);

robotOperator.expand(nodeIdentifier);}

Beispiel (1)

de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 67: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 67

@RobotKeywordspublic class TreeTableKeywords {

@RobotKeyword("Expands a node in my tree table.")@ArgumentNames({ "nodeIdentifier" })public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

System.out.println("*INFO* " + "expandMyTreeTableNode: " + nodeIdentifier);

ContainerOperator mainframe = (ContainerOperator) Context.getContext();

JTree theTree = (JTree) treetable.getCellRenderer(0, 0);

JTreeOperator jemmyOperator = new JTreeOperator(theTree);TreeOperator robotOperator = new TreeOperator(jemmyOperator);

robotOperator.expand(nodeIdentifier);}

Beispiel (1)

de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 68: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 68

API / Kommunikation mit dem Framework

Expand My TreeTable Node Historie|Herzlich willkommen beim...

${actual_title}= Get Selected Window Title

welcome-jfs.robot

public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

System.out.println("*INFO* " + "expandMyTreeTableNode: " + nodeIdentifier);

ContainerOperator mainframe = (ContainerOperator) Context.getContext();

TreeTableKeywords.java

Page 69: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 69

API / Kommunikation mit dem Framework

Expand My TreeTable Node Historie|Herzlich willkommen beim...

${actual_title}= Get Selected Window Titlewelcome-jfs.robot

public void expandMyTreeTableNode(String nodeIdentifier) throws Exception {

System.out.println("*INFO* " + "expandMyTreeTableNode: " + nodeIdentifier);

ContainerOperator mainframe = (ContainerOperator) Context.getContext();

…TreeTableKeywords.java

Page 70: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 70

public class TestData {private final String nodeIdentifier = "Historie|Herzlich willkommen beim...";

public String getNodeIdentifier() {return this.nodeIdentifier;

}}

API - Rückgabewerte

${testdata}= Create Test Data

Expand My TreeTable Node ${testdata.getNodeIdentifier()}

welcome-jfs.robot

@RobotKeyword("Creates a pojo!")public TestData createTestData() {return new TestData();

}PojoExampleKeywords.java

TestData.java

Page 71: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 71

public class TestData {private final String nodeIdentifier = "Historie|Herzlich willkommen beim...";

public String getNodeIdentifier() {return this.nodeIdentifier;

}}

API - Rückgabewerte

${testdata}= Create Test Data

Expand My TreeTable Node ${testdata.getNodeIdentifier()}

welcome-jfs.robot

@RobotKeyword("Creates a pojo!")public TestData createTestData() {return new TestData();

}PojoExampleKeywords.java

TestData.java

Page 72: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 72

public class MyRobotLibrary extends AnnotationLibrary {public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL"; public MyRobotLibrary() {super(Arrays.asList("de/aformatik/robotlib/kw/*"));

}}

API - Klassenkonstanten

MyRobotLibrary.java

Page 73: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 73

public class MyRobotLibrary extends AnnotationLibrary {public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL"; public MyRobotLibrary() {super(Arrays.asList("de/aformatik/robotlib/kw/*"));

}}

JavalibCore

MyRobotLibrary.java

@Autowiredprivate TreeTableKeywords treeTableKeywords;

@RobotKeyword("Processes a pojo!")@ArgumentNames({ "testData" })public void processTestData(TestData testData) throws Exception { new TreeTableKeywords().expandMyTreeTableNode(testData.getNodeIdentifier());

}

de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 74: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 74

public class MyRobotLibrary extends AnnotationLibrary {public static final String ROBOT_LIBRARY_SCOPE = "GLOBAL"; public MyRobotLibrary() {super(Arrays.asList("de/aformatik/robotlib/kw/*"));

}}

JavalibCore

MyRobotLibrary.java

@Autowiredprivate TreeTableKeywords treeTableKeywords;

@RobotKeyword("Processes a pojo!")@ArgumentNames({ "testData" })public void processTestData(TestData testData) throws Exception {this.treeTableKeywords .expandMyTreeTableNode(testData.getNodeIdentifier());

}

de/aformatik/robotlib/kw/TreeTableKeywords.java

Page 75: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 75

Fragen / Kontakt / Download

aformatik-Stand (Nr. 5) im Foyer vor dem Hegel Saal

[email protected]

Testsuite verfügbar unter:

http://www.aformatik.de/training/beispielprogramme.html

Homepage: http://www.aformatik.de

Page 76: Eine Einführung in das automatisierte Testen mit dem Robot ...2015.java-forum-stuttgart.de/_data/E3_Gauss.pdf · aformatik Training & Consulting GmbH & Co. KG 3 Vorstellung des Robot-Frameworks

aformatik Training & Consulting GmbH & Co. KG 76

Quellen

http://robotframework.org

Pekka Laukkanen: Data-Driven and Keyword-Driven Test Automation Frameworks,

2006, Master Thesis, Helsinki University of Technology

http://www.heise.de/developer/artikel/Automatisierte-Tests-mit-dem-Robot-Framework-

1834917.html, 2013