44
Automating Device Certifications with Robot Framework Pratik Lotia

Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

  • Upload
    others

  • View
    25

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Automating Device Certifications with Robot Framework

Pratik Lotia

Pratik Lotia

Page 2: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

RobotFrameworkIntroduction•  Opensourcegenerictestautomationframeworkforacceptancetesting

•  KeyworddrivenapproachsupportedwithseverallibrariesinPython&Java

•  Idealimplementationwithhighleveltestspre-writtenandnetworkengineersusingkeywordstodevelopframework

•  Notspecificallymadefornetworkbasedtesting

•  Datadriventestcases•  OSandapplicationindependent

2|

Page 3: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

RobotFrameworkMajorComponents

3|

Framework

Definedependencies&pointersTestCases

Ø  KeywordsØ  Variables

PythonCode

Functions

Ø  GenericØ  SingletaskØ  ArgumentsØ  ReturnValue

DataSet

ConfigurationFilesPointers

Server/VMSSH/NETCONF

Router/Firewall/Switch/LoadBalancer

Page 4: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Structure

4|

Page 5: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

FrameworkFormat

Ø Extensionbased•  HTML•  TSV–spreadsheet,programmatic•  Plaintext•  reST(HTMLcompiled)

5|

Page 6: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

FrameworkStructure•  Modularmodel•  Structurecombines

§  Settings§  Pre-testsetup§  Testcriteria§  Post-testcleanup

•  EachTesthasatrue/falseoutcome•  EachTesthas1ormorefunctions•  Top-downapproachforTestCase

§  Onefail,allfailmodel

6|

Page 7: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

FrameworkSample

7|

Page 8: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

RobotCommandOptions•  robot/path/to/file.robot•  Optionsto:

§  Setdocumentation§  Setsuite,reportname§  Settags,variables§  Rerunfailedtests§  Run/excludecertaintests§  Setlogginglevel,outputlevel§  Settimestamp§  Errorhandling

8|

Page 9: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

StyleConventions

9|

Field Convention Example/CommentsVariable Nameinside${} ${mgt_ip_addr)FunctionName Keyword(s)withorw/

spaceCheckInterfaceConfigcheck_interface_config

PassingVariables

Leave>4whitespacesbetweenfunction&variable

ShowInterface${mgt_ip_addr}${user}${passwd}

Notes Under[Documentation]intestcases

Testcase:checkinterfaceconfig[Documentation]LoadandverifyIP

Variables Defineseparatelyyamlfile

Helpstokeepframeworkgenericanddatadriven

Framework Tabularmodel Equalspacing

Page 10: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

CreatingTestCase•  Whitespacesignored*•  Keyword(What?)•  Library+Pythoncode•  Arguments:

– Mandatory–  Default

•  ReturnValue•  SingleTest

10|

Page 11: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example1–OperationalStatusofDevice–Framework

11|

Page 12: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example1–Variables

12|*Fakecredentialsonthisandsubsequentslides

Page 13: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example1–PythonCode

13|

Page 14: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example1-Results

14|

Page 15: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Results–ExecutiveSummary

15|*Failedtestmaybearesultofmisconfigurationandnotafailureofthedevice

Page 16: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Results–DetailedLogs

16|*Failedtestmaybearesultofmisconfigurationandnotafailureofthedevice

Page 17: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

SuiteSetupandTeardown

17|

Page 18: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

TroubleshootingErrors•  Defaulterrorsareminimal•  Tedioustolookathtmlforerrors•  LoggingmoduleinPython•  Similartoprintstatements•  Printswhilerunningtests

18|

Page 19: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Libraries•  StandardLibraries

§  Built-inØ  RunwithconditionsØ  EvaluationØ Matchingexpectedbehavior

§  ProcessorientedØ  ControlprocessexecutionØ  FetchprocessattributesØ  Switchprocess

19|

Page 20: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Libraries•  StandardLibraries

§  DateTimeØ  DateandTimeconversionsØ  Addingtime/dateØ  Subtractingtime/date

§  OSlevelfunctionsØ  Directorychanges/verificationØ  Filechanges/verification(copy,size)Ø  EnvironmentvariablesØ Merge/List

20|

Page 21: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Libraries•  StandardLibraries

§  StringfunctionsØ  Lengthcontrol/verificationØ  BehaviormatchingØ  Byteconversion

§  CollectionsØ  ControlLists/DictionariesØ  Behaviormatching

§  Dynamicinput,Telnet§  Screenshots

21|

Page 22: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Libraries•  ExtendedLibraries

§  Selenium,SeleniumwithAngularJS§  Suds(SOAP),MQTT,Faker§  SSH,Ncclient,Django,FTP§  Database,HTTP,Archive

22|

Page 23: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Tagging•  Classifyingtestcases&providing

metadata•  Reportshowsstatisticsbasedon

tags•  Include/Excludeexecutionofspecific•  Tags•  Tagsforcritical,non-critical,trivial•  Types

§  Forcetags§  Defaulttags§  Customizedtags

23|

Page 24: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Editor•  RIDE–Standaloneeditor•  Pluginsforvariouseditors

–  Eclipse–  Sublime–  Vim–  Emacs–  Gedit–  Notepad++

24|*https://www.youtube.com/watch?feature=player_embedded&v=6F_xGKdoN1E

Page 25: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example2-Framework

25|

Page 26: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example2-Variables

26|

Page 27: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example2–PythonCode

27|

Page 28: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Loops•  ‘For’Loop•  Repetitivetasks•  Keyword/Variable

28|

Page 29: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

AdditionalTools•  Rebot

§  ProcessXMLoutput§  Generatehtmlreports§  CombineorMergereports

•  Libdoc§  GenerateDocumentation

•  Tidy§  Cleanup/Changeformat

•  DbBot§  ReportstoSQLite§  Unifystorageofreports

29|

Page 30: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

AdditionalTools•  RobotCorder

§  RecordGUIactions§  HTMLframeworkgeneration

•  Pabot§  Parallelexecution§  Time

•  Fixml§  Fixingincompletexmlresults

•  Mabot§  Manualtestswithcompatibleoutputs

30|

Page 31: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

API•  Runningcodeviacode!•  APIfunctionstoruntestsalongwithoptions•  Includesallbasictoolssuchasrebot,libdoc,tidy•  Retrieveresults•  CustomizereportsHTML/XMLformat•  UsestandardlibrarieswithAPI•  Specifyvariablesandresources

31|

Page 32: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example3-Framework

32|

Page 33: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example3-Variables

33|

Page 34: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example3–PythonCode

34|

Page 35: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

DosandDon’ts

35|

•  Dos§  Documentation(options)§  Short&easynaming§  What,nothow

§  Tabularuniformity

§  Genericandsimpleframework

Page 36: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

DosandDon’ts

36|

•  Dos§  Logicincode§  Datadriven§  Checks§  Syntax(Given,When,Then)

•  Don’ts

§  Dependencies§  Granulartest§  Hardcodedvariables§  Sleepinginplaceofpolling

Page 37: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example4-Framework

37|

Page 38: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example4-Variables

38|

Page 39: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Example4–PythonCode

39|

Page 40: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Demo

40|

Page 41: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Summary•  RobotAutomationFrameworkprovidesseveralusecasescenariosfornetwork

automation•  Keywordbasedacceptancedriventests•  Reusegenerictestlibraries•  Separationofcomponentsallowcustomizationandeaseofunderstanding•  Simplifyautomationofworkflows

41|

Page 42: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Resources•  https://github.com/robotframework/robotframework/blob/master/INSTALL.rst•  http://www.slideshare.net/pekkaklarck/robot-framework-introduction•  https://github.com/robotframework/QuickStartGuide/blob/master/QuickStart.rst•  http://robotframework.org/robotframework/#user-guide•  https://github.com/robotframework/HowToWriteGoodTestCases/blob/master/

HowToWriteGoodTestCases.rst•  http://robotframework.org/robotframework/#standard-libraries•  https://robot-framework.readthedocs.io/en/latest/

42|

Page 43: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

[email protected] @pratiklotia

ThankYouv Questions?

Page 44: Automating Device Certifications with Robot Framework · Robot Framework Introduction • Open source generic test automation framework for acceptance testing • Keyword driven approach

Backupslides

October2,2018|Charter:Confidential 44|