Robot framework - SAST Väst Q3

23
Robot Framework A tool for automated acceptance testing

Transcript of Robot framework - SAST Väst Q3

Robot FrameworkA tool for automated acceptance testing

Me, My self and I Anders Arnholm

• Umeå Universitet

• Open Software ▶ HiQ

• Mecel ▶ Delphi

• HiQ

Acceptance testing

formal testing with respect to user needs, requirements, and business processes conducted to determine whether or not a system satisfies the

acceptance criteria and to enable the user, customers or other authorized entity to determine whether or not to accept the system.

Standard glossary of terms used in Software Testing, Version 2.1. ISTQB. 2010.

Automated

the technique, method, or system of operating or controlling a process by highly automatic means, as by electronic devices, reducing human

intervention to a minimum

dictionary.com

Acceptance test driven development

• A way of running Agile Development Project

• Inspired by Test Driven Development

• Product Owner + Tester + Developer refines a story into an automated acceptance test

• Development until the test passes

What is Robot Framework

• Test automation framework

• Implemented in python

• Open source

• Keyword-driven syntax

ArchitectureTest Data

Robot Framework

Test Libraries

Test Tools

System under test

Demo time

Keyword driven test

*** Test Cases *** User can log in with a valid password Attempt to Login with Credentials [email protected] P4ssw0rd Should Be Logged In [email protected]

User cannot log in with bad password Attempt to Login with Credentials [email protected] wrong Error Should Be Incorrect password

Gherkin Style

*** Test Cases *** The count should increase Given a logged in user And the click counter is 0 When the user clicks the button Then the click counter should be 1

Data driven tests*** Test Cases *** Invalid email [Template] Creating a user with invalid email should fail test_user Invalid email a+b@:w Invalid email

*** Keywords *** Creating a user with invalid email should fail [Arguments] ${username} ${errormessage} Attempt to create user with Credentials ${username} 12345 Error should be ${errormessage}

Custom Keywords*** Keywords *** Should Be Logged In [Arguments] ${username} Element Should Contain id=login-name-link ${username}

Error Should Be [Arguments] ${errormessage} [Timeout] 2 minutes Element Should Contain id=login-dropdown-list ${errormessage}

Extensible libraries#!/usr/bin/env python import json import time

def should_have_error_message(self, jsondata): print '*INFO:%d* JSON: %s' % (time.time()*1000, jsondata) questions = json.loads(jsondata) if not u'errorMessage' in questions: raise Exception(u'No error message in answer')

Variables*** Variables *** ${SERVER} localhost:3000 ${BROWSER} chrome ${DELAY} 0.1 ${pageurl} http://${SERVER}/

*** Test Case *** My variable example ${result}= Get page counter Greater Than 30 ${pagecounter}

pybot --variable BROWSER:safari mytest.robot

Test tagging*** Settings *** Force Tags sast Default Tags HiQ Gothenburg

*** Test Cases *** Page have greeting [Tags] smoke critical Page should contain Welcome

Page have copyright [Tags] smoke optional Page should contain ©2015

Page have last Page should contain SAST

Reports

Logs

Existing libraries• Standard Libraries

• OperatingSystem, Screenshot, String, Dialogs, XML, …

• External Libraries

• Selenium, Appium, SSH, Database,

• Project/Team specific

• Easy to make your own

Test data formats Also known as test file formats

• HTML (.html, .htm, .xhtml)

• TSV - tab separated values (.tsv)

• plain text (.txt, .robot)

• reStructured text (.rst, .rest)

Editors

• RIDE

• Plugins for IntelliJ, Eclipse, Vim, Emacs, SubLime, TextMate…

• Spreadsheet applications, Excel, Numbers or Calc

Easy Integration• Test suits from files and directories

• Supports any versioning system, e.g. use git

• Simple command line interface

• External tools and scripts can start tests

• Output also to XML

• Machine readable

• Easy to combine

• Plugins for common CI tools

• Jenkins, Ant, Maven