Scripting Techniques Models and Analysis of Software Lecture 10 Copyright, 2003 Jerzy R. Nawrocki
Plan wystąpienia Linear scripts Structured scripting Shared scripts Data-driven scripts Keyword-driven scripts
Linear scripts Linear script = A script obtained by recording a test case performed manually. Rational Robot & SQABasic User actions & result comparison 10’ manual test = 20’ – 120’ to automate (comparisons)
Linear scripts - Advantages No upfront work or planning. Quick starting. An audit trail of what was actually done. Programming skills not required. Good for demonstrations.
Linear scripts - Disadvantages Labor-intensive process (2-10 longer than manual testing. Low reusability and evolvability (‘from scratch’ each time). Low robustness (unexpected events).
Plan wystąpienia Linear scripts Structured scripting Shared scripts Data-driven scripts Keyword-driven scripts
Structured scripting Structured script = A script with structured programming instructions. Sequence, selection (if), iteration (for) SQABasic If Message = ‘Replace existing file?’ LeftMouseClick ‘Yes’
Structured scripts – Advantages and Disadvantages + More robust scripts (unexpected events under control). + Repeated things can be shortened with a loop statement. - More compicated (resemble programs and need debugging).
Plan wystąpienia Linear scripts Structured scripting Shared scripts Data-driven scripts Keyword-driven scripts
Shared scripts Shared script = A script used (shared) by more than one test case. SQABasic Call ScribbleOpen (‘countries’) FocusOn ‘Scribble’ SelectOption ‘List/Add Item’... Call ScribbleSaveAs (‘countries2’)
Plan wystąpienia Linear scripts Structured scripting Shared scripts Data-driven scripts Keyword-driven scripts
Data-driven scripts Data-driven scripting = Test inputs stored in a separate (data) file. countries, Sweden, USA, countries2 countries, France, Germany, test2 countries, Austria, Italy, test3
Data-driven scripts Data-driven scripting = Test inputs stored in a separate (data) file. OpenFile ‘ScribbleData’ For each record in ScribbleData Read INPUTFILE Read NAME1 Read NAME2 Read OUTPUTFILE Call ScribbleOpen (INPUTFILE) FocusOn ‘Scribble’ SelectOption ‘List/Add Item’ FocusOn ‘Add Item’ Type NAME1 LeftMouseClick ‘OK’... EndFor countries, Sweden, USA, countries2 countries, France, Germany, test2 countries, Austria, Italy, test3 ScribbleData Control script
A more sofisticated data-driven script OpenFile ‘ScribbleData’ Read INPUTFILE Call ScribbleOpen (INPUTFILE) Go to next record (ie row) For each record in ScribbleData Read ADDNAME If ADDNAME <> Blank Then { FocusOn ‘Scribble’ SelectOption ‘List/Add Item’ FocusOn ‘Add Item’ Type ADDNAME LeftMouseClick ‘OK} Read MOVEFROM Read MOVETO... EndFor ScribbleData countries Sweden USA 41 Norway 2 7 countries2 Control script
Data-driven scripts Software under test Key automated regression test cases Additional automated regression test cases
Plan wystąpienia Linear scripts Structured scripting Shared scripts Data-driven scripts Keyword-driven scripts
Keyword-driven script = A data-driven scripts augmented with keywords representing user actions. SQABasic??? ScribbleOpen countries AddToList Sweden USA SaveAs countries2 For each TEST_ID OpenFile TEST_ID For each record in test file Read KEYWORD Call KEYWORD EndFor CloseFile TEST_ID EndFor Test file Control script ScribbleOpen... AddToList... SaveAs... Supporting scripts
Summary Most important: Keyword-driven scripting. Most important: Keyword-driven scripting. Self-documenting scripts Self-documenting scripts Script pre-processing: Script pre-processing: Beautifier Beautifier Static analysis Static analysis General substitution General substitution
Bibliography M. Fewster, D. Graham, Software Test Automation, Addison-Wesley, Harlow, M. Fewster, D. Graham, Software Test Automation, Addison-Wesley, Harlow, 1999.
Questions?
Quality assessment 1. What is your general impression? (1 - 6) 2. Was it too slow or too fast? 3. What important did you learn during the lecture? 4. What to improve and how?