This document discusses various techniques for automating test scripts, including linear scripts, structured scripts, shared scripts, data-driven scripts, and keyword-driven scripts. Linear scripts record manual test cases but are vulnerable to changes. Structured scripts add control structures but require programming skills. Shared scripts reuse code through functions or libraries. Data-driven scripts separate test data from the driver script but both need updating. Keyword-driven scripts address this by putting test logic in a separate file from the single driver script. The document examines the pros and cons of each technique.
2. Hello, my name is Zhu Zhong (钟
柱)
12+ years, working on
automation test tools
Work(ed, ing) for
• Nortel
• Alcatel-Lucent
I like
• Write code
• Test
automation
• Drawing
• BBQ
• Ocarina
3. A Good Book
O 13+ years passed so far, automation scripting
techniques haven’t changed since the
publishing of this book.
O All the ideas of this slides come from my
understanding of this book plus my experience
• by Mark Fewster/ Dorothy Graham
• Published: September, 1999
4. What’ll We be Talking About?
O We will NOT talk about
O How to use an automation test tool
(EasyTest , QTP, Robot Framework, etc)
O Any specific testing techniques (GUI, Web,
etc)
O We will talk about
O Automation test scripts
O Types of scripts & their differences
O Which script technique to choose
5. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
6. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
7. Linear Scripts
O A Linear script is what you end up with
when you record a test case performed
manually.
(AutoIt)
9. Linear Scripts
O Good
O Quick start automation
O Demonstration or training
O Prepare test data
O Bad
O Hard coded data into scripts
O Vulnerable to changes
O No sharing or reuse
10. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
12. Structured Scripts
O Good
O More robust
O Reuse
O Bad
O Require programming skills
O More complex
O Test data still ‘hard-coded’ into the script
13. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
14. Shared Scripts
O Shared scripts are scripts that are used (or
shared) by more than one test case.
O May be called reusable script/function library
O Hard-coded values -> variables
15. Shared Scripts
– an example
(EasyTest)
Convert shared script to
HOST.checkLinuxVersion
Test case is simplified: just need to call shared script HOST.checkLinuxVersion
16. Shared Scripts
– shared scripts/functions makes a test case
easier to read/maintain
This is a real test case we used to test EasyTest
(Squish)
17. Shared Scripts
O Good
O Similar tests will take less effort to
implement
O Reuse: eliminates repetitions.
O Keep the changes to a minimum
O Bad
O Hard to track/find scripts, documents,
names and store.
O Shared scripts are often specific to part of
the system under test.
18. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
19. Data-Driven Scripts
O A data-driven script stores test data
(inputs & expected outcomes) in a
separate (data) file rather than in the
script itself.
21. Data-Driven Scripts
- Let’s test addition on a calculator
Test Case(s) = Test Data + Driver Test Script
(Python)
22. Data-Driven Scripts
O Good
O Similar tests can be added very quickly.
O Adding new tests can be done by testers w/o
knowledge of the automation test tool scripting
language.
O Separation of roles: Tester (test data file) + automation
designer (driver scripts)
O Bad
O Driver script is complex. Need good programming
skills.
O One driver script is only good for one kind of testing.
O Changes to either data file or driver script, you’ll need
to change both
23. Different Scripting Techniques
O Linear scripts
O Structured scripts
O Shared scripts
O Data-driven scripts
O Keyword-driven scripts
24. How to test square root 𝑛?
Can we re-use addition.py test script?
Driver Test
Script
Data File System
Under Test
Both Data File & Driver Test Script can’t be re-used, need to create new ones
25. Keyword-Driven Scripts
O Keyword-driven comes from Data-driven to
overcome some limitations:
O One driver script only works for one kind of
tests
O “What to test” is built into both the data file and
driver script, so they need to be synchronized.
O Can we ?
O Use one “driver script” to drive all data files?
O Put “What to test” in just one data file?
26. From Data-Driven to Keyword-Driven
Driver Test
Script
Data File System
Under Test
Driver
Test
Script
System
Under Test
Data FileData File
Data FileData FileTest Data
File
Keyword
Scripts
Test data
What to test
How to test
Control
logic
28. Keyword-Driven Scripts and Other Scripts
-Mindset change: What to test vs. How to test
Other scripts: Detailed info on what
& how to test
Keyword-Driven scripts:
Just what to test
Sometimes “what to test”
is described in your test
script comments/document
29. Keyword-Driven Scripts
-Separation of Concerns
Driver
Test
Script
System
Under Test
Data FileData FileTest Data
File
Keyword
Scripts
Test data +
What to test
How to testControl
logic
• Tester
• No need of
programming
skills
• Use
Excel/notepad to
edit Test Data
File
• Tool Designer
• Strong
programming
skills
• Use C++/ Java/
Python/Ruby to
code the 1 and
only 1 driver
test script
• Automation Expert
• Familiar with a scripting
language (Python/ TCL/ test
tool language)
• Good knowledge of the
System Under Test
30. Keyword-Driven Scripts
O Good
O All goodies from Data-Driven
O Test data file is also readable test document
O Separation of concerns
O Mindset change: What to test vs. How to test
O Bad
O Seen as silver bullet, but it’s not
O Require good knowledge and experience on
both programming and System Under Test to
plan, design and maintain keywords.
O If not well planned, you’ll be happy from the
beginning and suffer/fail in the near future.
31. I have a question for
you.
Which scripting technique is
better?
32. Do you have a question for
me?
Email zhongzhu@ymail.com
Or follow me on Sina Weibo @钟柱
Editor's Notes
If it can’t be found quickly people will write their own version of it.