29
W20 - A Lean And Mean Approach To Model-Based Testing Bert Zuurke Logica Netherlands

Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Embed Size (px)

DESCRIPTION

EuroSTAR Software Testing Conference 2010 presentation on A Lean And Mean Approach To Model-Based Testing by Bert Zuurke. See more at: http://conference.eurostarsoftwaretesting.com/past-presentations/

Citation preview

Page 1: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

W20 - A Lean And Mean Approach To Model-Based Testing

Bert Zuurke

Logica Netherlands

Page 2: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Presenting

• I will present a method :

– where the test scripts are generated from state transition diagrams

– and populated with test data from an Excel spreadsheet.

Page 3: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Including

• Demonstrating the use of open source tools

– For making state transition diagrams

– For generating test scripts

– For recording test results

– For automating tests

Page 4: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Not included

• This is not a tutorial on model based testing

• This is not a tutorial on how to test with state transition diagrams

• This is not a demonstration of all features of all the tools

Page 5: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Lean and mean

• Only open source

– Low costs to start with MBT

• Understandable and usable by any average tester

Page 6: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

We all use models

Hmmm…if I want to make a note

than I need to start Notepad, enter my text,

save it and close Notepad

start

Save

Type text

CancelNo

Page 7: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

A state transition diagram

START State Action END State

Start Start notepad Notepad running

Notepad running Type text Text entered

Text entered Close window Save the changes?

Save the changes? No Notepad not running

Save the changes Cancel Text entered

startSave

Type text

CancelNo

Start Notepad

Page 8: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

And also depictured as

Save

Type text

CancelNo

Page 9: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

How to test using state transition diagrams

Test scenario’s

All states

All Edges

Statistics:- Edge coverage- State coverage- Test cases coverage

Page 10: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Where is the test data?

Page 11: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Endless edges?

For every test case we need an extra edge

Page 12: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Why using Excel for test data?

Action wordWhat to do

Arguments= test data

Field labels

Page 13: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Use of excel

Edge name Label

Type Text 1 A note for Eurostar 2010

2 Another line

3 Last line to type

Page 14: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Putting it all together

Use Model State Diagram for navigation

Use Excel for the test data

Page 15: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Add a user interface

Model engine

Testdata

Model state diagram

SOAP Request SOAP Repley

Testdata

Test engine

• Offline mode

• Online mode

• Test automation

Operation Modes

Navigation

Page 16: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Details

Page 17: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Demo YeDmake a transition diagram for Notepad

The following sheets are placeholders for the real demonstration.

Page 18: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Generate Excel worksheet

Page 19: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Generate an Excel worksheet (2)

Page 20: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Supply the test data

Page 21: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Run and have fun!

Page 22: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Automation

Test Automation can be added in the same way as with keyword driven tests

keyword testdata3testdata2testdata1

Step 1: action (enter testdata1 in field 1)Step2: action …

Notepad running

Text added

Add Text

Edge name testdata1

Func Add_textsend(“A note for Eurostar 2010{ENTER}”)Endfunc

Page 23: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Automation (2)

Per step automatione.g.Start the application run("Notepad.exe")Enter text send(“A note for Eurostar 2010{ENTER}”)Close the window WinClose("Untitled - Notepad","")Cancel “Save the changes” ; click No button

ControlClick("Notepad","","[CLASS:Button; INSTANCE:2]")

Do not “Save the changes” ; click No buttonControlClick("Notepad","","[CLASS:Button; INSTANCE:2]")

How it is done:1. Generate an autoit script template2. Add programming statements for each step inside the functions3. Compile with engine4. Test the test

Page 24: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Demo: generate the programming frameand add the statements to automate the test

Switch $namecase “e_Type_A”$nextaction=e_Type-A($sproc,$itestcase,$aArguments)case “e_Close”$nextaction=e_Type-A($sproc,$itestcase,$aArguments)

End switch

Func a_Type_A($Proc,$testnr,$aData); do the action on the SUTWinWait("Untitled - Notepad","")If Not WinActive("Untitled - Notepad","") Then WinActivate("Untitled - Notepad","")WinWaitActive("Untitled - Notepad","")send()Endfunc ;e_Type_A

Page 25: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Run again and have more fun

This page is a placeholder for the real life demo

Page 26: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Extensions to the model

Use of guards and expressions

Edge can only be used if the condition is true:Test_entered=true

Expressions can change the stateVariables:Test-entered=true

Syntax:Name[guard1;guard2;]/expression1;expression2

Page 27: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Run again and have more fun

This page is a placeholder for the real life demo

Page 28: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Summary

• I have demonstrated the use of open source tools√ For making state transition diagrams√ For generating test scripts√ For recording test results√ For automating test√ Can be used for a start with Model based testing.

• Commercial tools add more features• Better GUI• More input models• Data generation from class diagrams• Integration with QTP and other tools

Page 29: Bert Zuurke - A Lean And Mean Approach To Model-Based Testing - EuroSTAR 2010

Thank you