dsr testing (part 1)
TRANSCRIPT
![Page 1: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/1.jpg)
Software Testing@Steve_Upton
![Page 2: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/2.jpg)
Who am I?● Steve Upton● English / Welsh / British / Irish(?)● BSc. Computer Science (Cardiff University)● Physics & Astronomy (Open University)● IBM (6 years)
○ Messaging○ OASIS MQTT TC member○ Working with clients on Microservice systems○ London μService user group
● HERE Berlin (9 months)○ Microservices○ Robots!
![Page 3: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/3.jpg)
Who are you?
![Page 4: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/4.jpg)
![Page 5: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/5.jpg)
Exclusive use of white box testing in a test-phase will:
a) Ensure the test item is adequately tested
b) Make the need for black-box testing redundant
c) Run the risk that the requirements are not satisfied
d) Suffice for the unit testing phase
![Page 6: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/6.jpg)
Which is not in sequence in Step 11 of the Software Testing process?
a) Assess development plan and status
b) Develop the test plan
c) Test software design
d) Test software requirement
![Page 7: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/7.jpg)
Software Test Documentation is described in which standard?
a) IEEE 730-2014
b) IEEE 829-2008
c) IEEE 830-1984
d) IEEE 1012-2012
![Page 8: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/8.jpg)
![Page 9: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/9.jpg)
![Page 10: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/10.jpg)
Understand importance testing
Understand how to test well
Be ready for a testing role
Be ready for a test interview!
![Page 11: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/11.jpg)
Why do we test?
![Page 12: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/12.jpg)
![Page 13: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/13.jpg)
![Page 14: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/14.jpg)
![Page 15: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/15.jpg)
![Page 16: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/16.jpg)
![Page 17: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/17.jpg)
![Page 18: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/18.jpg)
$370 million!
![Page 19: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/19.jpg)
![Page 20: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/20.jpg)
![Page 21: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/21.jpg)
![Page 22: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/22.jpg)
![Page 23: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/23.jpg)
$475 million!
![Page 24: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/24.jpg)
So, why do we test?
![Page 25: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/25.jpg)
What is the purpose of a tester?
![Page 26: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/26.jpg)
To write lots of tests?
![Page 27: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/27.jpg)
To write lots of tests?
No
![Page 28: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/28.jpg)
To run lots of tests?
![Page 29: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/29.jpg)
To run lots of tests?
Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
![Page 30: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/30.jpg)
To run lots of tests?
Noooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
![Page 31: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/31.jpg)
Find all the bugs?
![Page 32: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/32.jpg)
Find all the bugs?
![Page 33: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/33.jpg)
Find all the bugs?
![Page 34: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/34.jpg)
Find bugs?
![Page 35: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/35.jpg)
Find (lots of) bugs?
![Page 36: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/36.jpg)
Impact of the bug matters!
Find (lots of) bugs?
![Page 37: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/37.jpg)
Improve quality?
![Page 38: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/38.jpg)
Improve quality?Better... but a bit vague
![Page 39: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/39.jpg)
Implications?
![Page 40: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/40.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
![Page 41: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/41.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
You are a code monkey
![Page 42: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/42.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
You are a code monkey
You are a code monkey
![Page 43: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/43.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
You are a code monkey
You are a code monkey
Your job is futile
![Page 44: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/44.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
You are a code monkey
You are a code monkey
Your job is futile
Your job never ends
![Page 45: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/45.jpg)
Implications?
Write lots of tests?
Run lots of tests?
Find all the bugs?
Find bugs?
Improve quality?
You are a code monkey
You are a code monkey
Your job is futile
Your job never ends
Everyone has that job
![Page 46: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/46.jpg)
What is the role of a tester?
![Page 47: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/47.jpg)
Richard Coppen@getnextid
![Page 48: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/48.jpg)
![Page 49: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/49.jpg)
![Page 50: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/50.jpg)
![Page 51: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/51.jpg)
![Page 52: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/52.jpg)
![Page 53: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/53.jpg)
The role of a tester is to quantify risk
Then use that information to make decisions and improve confidence and quality
![Page 54: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/54.jpg)
The role of a tester is to quantify risk
Then use that information to make decisions that improve confidence and quality
![Page 55: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/55.jpg)
How do we test?
![Page 56: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/56.jpg)
Testing LifecycleRequirements analysis
Test planning
Test development
Test execution
Test reporting
Test result analysis
Defect Retesting
Regression testing
Test Closure
![Page 57: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/57.jpg)
Test strategy
Test techniques
Defect management
Test metrics
![Page 58: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/58.jpg)
Test Strategy
![Page 59: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/59.jpg)
![Page 60: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/60.jpg)
Test early!
![Page 61: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/61.jpg)
![Page 62: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/62.jpg)
![Page 63: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/63.jpg)
![Page 64: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/64.jpg)
![Page 65: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/65.jpg)
![Page 66: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/66.jpg)
Lisa Crispin@lisacrispin
![Page 67: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/67.jpg)
![Page 68: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/68.jpg)
Business Facing
Technology Facing
![Page 69: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/69.jpg)
Business Facing
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
![Page 70: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/70.jpg)
Business Facing
Q2
Technology Facing
Sup
porti
ng th
e te
amC
ritique the productQ1
Q3
Q4
![Page 71: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/71.jpg)
Business Facing
Q2
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Q1
Q3
Q4
Automated Tools
Manual
![Page 72: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/72.jpg)
Business Facing
Functional testsStory testsPrototypesSimulations
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Unit testsComponent tests
ScenariosExploratory tests
Usability testsUAT
Alpha/Beta
Performance/LoadSecurity testing
-ility testing
Automated Tools
Manual
![Page 73: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/73.jpg)
Unit testing Functional testing
![Page 74: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/74.jpg)
Unit testing
Testing individual units of code
Functions, methods, classes etc.
Generally done by devs
Tests that the code is doing things right
Testing functionality (not a function!)
User interfaces
Generally done by testers
Tests that the code is doing the right thing
Functional testing
![Page 75: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/75.jpg)
Business Facing
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Automated Tools
Manual
![Page 76: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/76.jpg)
Business Facing
Functional tests
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Unit tests
Automated Tools
Manual
![Page 77: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/77.jpg)
Unit Testing
![Page 78: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/78.jpg)
Let’s test… string.index
![Page 79: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/79.jpg)
Let’s test… string.index
![Page 80: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/80.jpg)
Manual testing
Open a code prompt…
Quick to get going...
… but slow in the long run>>> "abcd".index("b");
1
![Page 81: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/81.jpg)
Automated testing#!/bin/bash
out=`python script.py`
if [ $out = 1 ]; then
echo "test passed"
else
echo "test failed"
fi
Same principle, but repeatable
Useful for regression testing
Requires tooling
![Page 82: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/82.jpg)
Standard library
xUnit based
Supported by other test runners
unittest
pip install pytest
xUnit based
No boilerplate, simpler syntax
py.test
![Page 83: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/83.jpg)
xUnitCollection of unit testing frameworks that share structure and functionality
Started with SUnit for Smalltalk
JUnit (Java), RUnit (R), NUnit (.NET) etc.
Object Oriented
![Page 84: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/84.jpg)
xUnit components
Test Case
Test Suite
Test Runner
Test Fixtures
![Page 85: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/85.jpg)
xUnit components - Test Case
![Page 86: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/86.jpg)
“A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular
program path or to verify compliance with a specific requirement.”
IEEE Standard 610 (1990)
xUnit components - Test Case
![Page 87: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/87.jpg)
“A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular
program path or to verify compliance with a specific requirement.”
IEEE Standard 610 (1990)
xUnit components - Test Case
![Page 88: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/88.jpg)
“A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular
program path or to verify compliance with a specific requirement.”
IEEE Standard 610 (1990)
xUnit components - Test Case
Inputs and expected outputs
Don’t get expected results = fail
![Page 89: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/89.jpg)
“A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular
program path or to verify compliance with a specific requirement.”
IEEE Standard 610 (1990)
xUnit components - Test Case
Inputs and expected outputs
Don’t get expected results = fail
All tests inherit from TestCase class
![Page 90: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/90.jpg)
“A set of test inputs, execution conditions, and expected results
developed for a particular objective, such as to exercise a particular
program path or to verify compliance with a specific requirement.”
IEEE Standard 610 (1990)
xUnit components - Test Case
Inputs and expected outputs
Don’t get expected results = fail
All tests inherit from TestCase class
Test methods start with test
Has at least one assert statement
![Page 91: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/91.jpg)
xUnit components - Test Suite
Collection of test cases
All test cases should be independent
Allows us to run specific sets of tests
![Page 92: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/92.jpg)
xUnit components - Test Fixture
Pre-requisites and cleanup need by one or more tests
Generate fake data, temporary databases etc. (context)
Includes cleanup!
unittest provides setUp() and tearDown() methods
![Page 93: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/93.jpg)
xUnit components - Test Runner
Runs test cases or test suites and returns results
unittest provides TextTestRunner but many others available
HTMLTestRunner outputs a HTML report
XMLTestRunner outputs XML
![Page 94: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/94.jpg)
class TestIndex(unittest.TestCase):
# Tests go here
if __name__ == '__main__':
unittest.main()
![Page 95: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/95.jpg)
def test_my_first_test(self):
![Page 96: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/96.jpg)
def test_my_first_test(self):
alphabet = "abcdefghijklmnopqrstuvwxyz"
str1 = "ab"
self.assertEqual(alphabet.index(str1), 0)
![Page 97: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/97.jpg)
$ python main.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
![Page 98: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/98.jpg)
Let’s test… string.index
![Page 99: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/99.jpg)
def test_value_error(self):
with self.assertRaises(ValueError):
alphabet = "abcdefghijklmnopqrstuvwxyz"
str2 = "not_in_the_alphabet"
alphabet.index(str2)
![Page 100: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/100.jpg)
# Run before each test
def setUp(self):
self.alphabet = "abcdefghijklmnopqrstuvwxyz"
# Run after each test
def tearDown(self):
return
![Page 101: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/101.jpg)
def test_value_error(self):
with self.assertRaises(ValueError):
self.alphabet.index('not_in_the_alphabet')
![Page 102: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/102.jpg)
Let’s test… string.index
![Page 103: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/103.jpg)
Golden Path Testing
Error Path Testing
Boundary Value Testing
Equivalence Partitioning
Defect clustering
Black Box/White Box
![Page 104: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/104.jpg)
Golden Path Testing
![Page 105: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/105.jpg)
Golden Path TestingTest the ideal data
Don’t do anything to induce errors
Don’t rock the boat
![Page 106: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/106.jpg)
Golden Path TestingTest the ideal data
Don’t do anything to induce errors
Don’t rock the boat
Danger of writing ‘easy’ tests
![Page 107: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/107.jpg)
Error Path TestingExtreme values (+∞, -∞ etc.)
Invalid values (string in place of int etc.)
Out of date data (expired password etc.)
Unusual values, characters ( Ю 屁)
Null values (“”, “ “, 0, null, undefined)
![Page 108: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/108.jpg)
Let’s test...
![Page 109: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/109.jpg)
Let’s test...
Exhaustive testing is impossible
![Page 110: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/110.jpg)
Equivalence Partitioning
Identify partitions of inputs eg.
- Age 0-18, 18-26, 26+
- 2n (32-64, 64-128, 128-256…)
- ≤1, 0, ≥1
![Page 111: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/111.jpg)
Equivalence Partitioning
Identify partitions of inputs eg.
- Age 0-18, 18-26, 26+
- 2n (32-64, 64-128, 128-256…)
- ≤1, 0, ≥1
Consider each group to be the equivalent
Only need to test 1 value per partition
![Page 112: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/112.jpg)
Equivalence Partitioning
Identify partitions of inputs eg.
- Age 0-18, 18-26, 26+
- 2n (32-64, 64-128, 128-256…)
- ≤1, 0, ≥1
Consider each group to be the equivalent
Only need to test 1 value per partition
30
31
32
33
34
35
...
...
![Page 113: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/113.jpg)
Boundary value testing
Identify partitions of inputs again
Test values on the edges of the partitions
![Page 114: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/114.jpg)
2
Boundary value testing
Identify partitions of inputs again
Test values on the edges of the partitions-2
-1
0
1
...
...
![Page 115: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/115.jpg)
Defect clustering
Defects tend to be clustered together
80% of bugs in 20% of code (Pareto principle)
![Page 116: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/116.jpg)
Defect clustering
Defects tend to be clustered together
80% of bugs in 20% of code (Pareto principle)
Adapt testing plans based on results!
![Page 117: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/117.jpg)
White Box testing Black Box testing
![Page 118: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/118.jpg)
White Box testing
Tests based on external interfaces
No knowledge of internals
Intuit error paths (test data selection)
Generally done by testers
Black Box testing
![Page 119: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/119.jpg)
White Box testing
Writing tests based on code
Uses knowledge of internals
Identify and test error paths in code
Generally done by developers
Tests based on external interfaces
No knowledge of internals
Intuit error paths (test data selection)
Generally done by testers
Black Box testing
![Page 120: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/120.jpg)
Business Facing
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Unit tests
Automated Tools
Manual
![Page 121: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/121.jpg)
![Page 122: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/122.jpg)
Let’s test… the Fibonacci sequence
![Page 123: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/123.jpg)
Let’s test… the Fibonacci sequence
import unittest
# Returns the nth Fibonacci number
def fib(n):
return;
![Page 124: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/124.jpg)
Let’s test… the Fibonacci sequenceclass TestFibonacci(unittest.TestCase):
def test_fib_1(self):
self.assertEqual(fib(1), 1)
if __name__ == '__main__':
unittest.main()
![Page 125: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/125.jpg)
Let’s test… the Fibonacci sequenceclass TestFibonacci(unittest.TestCase):
def test_fib_1(self):
self.assertEqual(fib(1), 1)
if __name__ == '__main__':
unittest.main()
![Page 126: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/126.jpg)
Let’s test… the Fibonacci sequence
$ python main.py
FFFFF
======================================================================
FAIL: test_fib_0 (__main__.TestFibonacci)
----------------------------------------------------------------------
Traceback (most recent call last):
File "main.py", line 15, in test_fib_0
self.assertEqual(fib(0), 0)
AssertionError: None != 0
![Page 127: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/127.jpg)
Let’s test… the Fibonacci sequence
def fib(n):
if n == 0: return 0
elif n == 1: return 1
else: return fib(n-1)+fib(n-2)
![Page 128: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/128.jpg)
Let’s test… the Fibonacci sequence
$ python main.py
.....
----------------------------------------------------------------------
Ran 5 tests in 0.000s
OK
![Page 129: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/129.jpg)
Let’s test… the Fibonacci sequence
def fib(n):
a,b = 0,1
for i in range(n):
a,b = b,a+b
return a
![Page 130: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/130.jpg)
Refactoring
![Page 131: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/131.jpg)
Refactoring
![Page 132: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/132.jpg)
Red
GreenRefactor
![Page 133: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/133.jpg)
Red
GreenRefactor
Test Driven Development(TDD)
![Page 134: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/134.jpg)
Business Facing
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Automated Tools
Manual
![Page 135: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/135.jpg)
Dan North@tastapod
![Page 136: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/136.jpg)
Where do we start testing?
![Page 137: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/137.jpg)
Where do we start testing?What do we test?
![Page 138: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/138.jpg)
Where do we start testing?What do we test?
(and what don’t we test?)
![Page 139: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/139.jpg)
Where do we start testing?What do we test?
(and what don’t we test?)
How much do we test in one go?
![Page 140: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/140.jpg)
Where do we start testing?What do we test?
(and what don’t we test?)
How much do we test in one go?How do we name our tests?
![Page 141: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/141.jpg)
Where do we start testing?What do we test?
(and what don’t we test?)
How much do we test in one go?How do we name our tests?
How do we understand why a test fails?
![Page 142: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/142.jpg)
Behaviour Driven Development (BDD)
![Page 143: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/143.jpg)
As a [user]
I want [feature]
so that [benefit]
![Page 144: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/144.jpg)
As a customer
I want to get coffee from the machine
so that I don’t have to make my own
![Page 145: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/145.jpg)
Given [some initial context]
When [an event occurs]
Then [ensure some outcomes]
![Page 146: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/146.jpg)
Given the coffee machine is installed
And the coffee machine has coffee
And I have deposited €1
When I press the coffee button
Then I should be served a coffee
![Page 147: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/147.jpg)
Given the coffee machine is installed
And the coffee machine has no coffee
And I have deposited €1
When I press the coffee button
Then I should be shown an error
And I should be have my €1 returned
![Page 148: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/148.jpg)
Feature: Some terse yet descriptive text of what is desired
Textual description of the business value of this feature
Business rules that govern the scope of the feature
Any additional information that will make the feature easier to understand
Scenario: Some determinable business situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some testable outcome is achieved
And something else we can check happens too
Scenario: A different situation
...
![Page 149: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/149.jpg)
Feature: Some terse yet descriptive text of what is desired
Textual description of the business value of this feature
Business rules that govern the scope of the feature
Any additional information that will make the feature easier to understand
Scenario: Some determinable business situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some testable outcome is achieved
And something else we can check happens too
Scenario: A different situation
...
![Page 150: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/150.jpg)
Feature: Some terse yet descriptive text of what is desired
Textual description of the business value of this feature
Business rules that govern the scope of the feature
Any additional information that will make the feature easier to understand
Scenario: Some determinable business situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some testable outcome is achieved
And something else we can check happens too
Scenario: A different situation
...
![Page 151: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/151.jpg)
BDD tools
freshen lettuce behave
![Page 152: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/152.jpg)
![Page 153: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/153.jpg)
GivenPut the system in a known state
Given there is coffee in the machine
↓
@given('the coffee machine is installed')
def step_impl(context):
context.coffee_machine = CoffeeMachine()
![Page 154: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/154.jpg)
Given
Given there is coffee in the machine
↓
@given('the coffee machine is installed')
def step_impl(context):
context.coffee_machine = CoffeeMachine()
Put the system in a known state
![Page 155: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/155.jpg)
When
When I press the coffee button
↓
@when('I press the coffee button')
def step_impl(context):
context.coffee_machine.push_coffee_button
Describe the key action
![Page 156: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/156.jpg)
When
When I press the coffee button
↓
@when('I press the coffee button')
def step_impl(context):
context.coffee_machine.press_coffee_button()
Describe the key action
![Page 157: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/157.jpg)
ThenObserve outcomes
Then I should be served a coffee
↓
@then('I should be served a coffee')
def step_impl(context):
assert context.coffee_machine.served_drink is "coffee"
![Page 158: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/158.jpg)
ThenThen I should be served a coffee
↓
@then('I should be served a coffee')
def step_impl(context):
assert context.coffee_machine.served_drink is "coffee"
Observe outcomes
![Page 159: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/159.jpg)
$ behave
Feature: A coffee machine that dispenses coffee # coffee_machine.feature:1
Scenario: run a simple test # coffee_machine.feature:3
Given the coffee machine is installed # steps/steps.py:4 0.000s
And the coffee machine has coffee # steps/steps.py:8 0.000s
And I have deposited 1 euro # steps/steps.py:12 0.000s
When I press the coffee button # steps/steps.py:16 0.000s
Then I should be served a coffee # steps/steps.py:20 0.000s
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
5 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.000s
![Page 160: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/160.jpg)
behave
pip install behave
Features go in a .feature file
Steps (Givens, Whens and Thens) go in steps/
![Page 161: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/161.jpg)
Exercise
![Page 162: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/162.jpg)
Should you use BDD?
![Page 163: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/163.jpg)
Should you use BDD?
More tooling, organisational requirements
![Page 164: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/164.jpg)
Should you use BDD?
More tooling, organisational requirements
Might not be applicable in all cases
![Page 165: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/165.jpg)
Should you use BDD?
More tooling, organisational requirements
Might not be applicable in all cases
Pick and choose!
describe('Array', function() {
describe('#indexOf()', function() {
it('should return -1 when value is not present', function() {
assert.equal(-1, [1,2,3].indexOf(4));
});
});
});
![Page 166: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/166.jpg)
Should you use BDD?
More tooling, organisational requirements
Might not be applicable in all cases
Pick and choose!
$ mocha
Array
#indexOf()
✓ should return -1 when value is not present
1 passing (9ms)
![Page 167: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/167.jpg)
Business Facing
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Automated Tools
Manual
![Page 168: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/168.jpg)
Business Facing
BDD
Technology Facing
Sup
porti
ng th
e te
amC
ritique the product
Auto/Manual
Automated Tools
Manual
![Page 169: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/169.jpg)
![Page 170: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/170.jpg)
![Page 171: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/171.jpg)
![Page 172: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/172.jpg)
![Page 173: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/173.jpg)
Integration testing
![Page 174: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/174.jpg)
![Page 175: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/175.jpg)
Integration testing
Testing more than individual components
![Page 176: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/176.jpg)
Integration testing
Testing more than individual components
Multiple approaches
- Big Bang
- Top Down
- Bottom Up
![Page 177: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/177.jpg)
Integration testing
Testing more than individual components
Multiple approaches
- Big Bang
- Top Down
- Bottom Up
May use fixtures (stubs and mocks)
![Page 178: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/178.jpg)
Test fixtures - Stubs‘Stub’ out functionality
Reply to calls with canned responses
Allows testing without dependencies
![Page 179: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/179.jpg)
Test fixtures - Stubs‘Stub’ out functionality
Reply to calls with canned responses
Allows testing without dependencies
pip install mock (Python 2)
from unittest.mock import MagicMock
dependency.method = MagicMock(return_value=5)
...
dependency.method(10)
>>> 5
![Page 180: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/180.jpg)
Test fixtures - MocksBasically stubs with expectations
from unittest.mock import MagicMock
dependency.method = MagicMock(return_value=5)
...
dependency.method(10)
...
dependency.method.assert_called_with(10)
![Page 181: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/181.jpg)
Let’s test … Conway’s Game of LifeCellular automaton
Set initial state and watch the system evolve
Complicated behavior from simple rules
![Page 182: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/182.jpg)
Let’s test … Conway’s Game of LifeGrid of cells
![Page 183: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/183.jpg)
Let’s test … Conway’s Game of LifeGrid of cells
Each cell can be on (alive) or off (dead)
![Page 184: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/184.jpg)
Let’s test … Conway’s Game of LifeGrid of cells
Each cell can be on (alive) or off (dead)
Each ‘step’, apply rules:
● Live cells with < 2 neighbours die (under population)
● Live cells with 2 - 3 neighbours live (stable)
● Live cells with > 2 neighbours die (over population)
● Dead cells with 3 neighbours live (reproduction)
![Page 185: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/185.jpg)
Let’s test … Conway’s Game of LifeGrid of cells
Each cell can be on (alive) or off (dead)
Each ‘step’, apply rules:
● Live cells with < 2 neighbours die (under population)
● Live cells with 2 - 3 neighbours live (stable)
● Live cells with > 2 neighbours die (over population)
● Dead cells with 3 neighbours live (reproduction)
![Page 186: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/186.jpg)
py.test
pip install pytest
Similar to unittest
Less boilerplate
Supports running unittest tests
![Page 187: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/187.jpg)
py.test$ pytest -v test_game_of_life.py
============================= test session starts =============================
platform linux2 -- Python 2.7.12, pytest-3.0.6, py-1.4.32, pluggy-0.4.0 --
/home/steve/Dev/dsr/dsr-testing-lab/exercise-pytest/venv/bin/python
cachedir: .cache
rootdir: /home/steve/Dev/dsr/dsr-testing-lab/exercise-pytest, inifile:
collected 1 items
test_game_of_life.py::test_advance_should_return_a_set PASSED
========================== 1 passed in 0.00 seconds ===========================
![Page 188: DSR Testing (Part 1)](https://reader034.vdocuments.pub/reader034/viewer/2022042515/58a3e1801a28ab7f0b8b623b/html5/thumbnails/188.jpg)
Exercise