SlideShare ist ein Scribd-Unternehmen logo
1 von 14
Testing
Will Weaver
What I Mean by Testing?
•

Automatic and repeatable checking that code
written works as expected.
•
•

Correct side effects

•
•

Correct result

Speedy enough

Writing tests prior to writing code
Why Test?
•

Reduce regression bugs

•

Increase code quality
•
•

•

Better design
Find problems early

Helps you know when you are done coding
Levels of Testing
•

Unit

•

Integration

•

System / End-to-End

•

Acceptance
Unit Testing
•

Testing small units

•

Test all cases / scenarios

•

Mock / Patch external calls
Unit Test Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# transaction.py
class Transaction(object):
def __init__(self, action, amount):
self.action = action
self.amount = amount

# bank_account.py
class BankAccount(object):
def __init__(self, initial_balance=0):
self.balance = initial_balance
self.transactions = [Transaction('initial', initial_balance)]
Unit Test Example (cont'd)
17 # test_bank_account.py
18 class DescribeBankAccount(BaseTestCase):
19
20
# Arrange
21
@classmethod
22
def configure(cls):
23
cls.init_balance = 10.0
24
cls.transaction = cls.create_patch('bank_account.Transaction')
25
26
# Act
27
@classmethod
28
def execute(cls):
29
cls.bank_account = BankAccount(cls.init_balance)
30
31
# Assert
32
def should_have_balance(self):
33
self.assertEqual(self.bank_account.balance, self.init_balance)
34
35
def should_create_transaction(self):
36
self.transaction.assert_called_once_with('initial', self.init_balance)
37
38
def should_have_transactions(self):
39
self.assertEqual(
40
self.bank_account.transactions, [self.transaction.return_value])
Integration Testing
•

Test interaction with dependencies / external
calls

•

Not as detailed as unit tests - no need to test
every scenario

•

Minimal mocking / patching
Integration Test Example
17 # test_bank_account.py
18 class DescribeBankAccount(BaseTestCase):
19
20
# Arrange
21
@classmethod
22
def configure(cls):
23
cls.init_balance = 10.0
24
25
# Act
26
@classmethod
27
def execute(cls):
28
cls.bank_account = BankAccount(cls.init_balance)
29
30
# Assert
31
def should_have_transactions(self):
32
self.assertEqual(
33
self.bank_account.transactions,
34
[Transaction('initial', self.init_balance)],
35
)
System / End-to-End Testing
•

Test public endpoints

•

Use full stack

•

No mocking / patching

•

Minimal to no inspecting of underlying side
effects - only results of calls

•

Run in a staging environment
System Test Example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

# transaction.py
class Transaction(object):
def __init__(self, action, amount):
self.action = action
self.amount = amount

# bank_account.py
class BankAccount(object):
def __init__(self, initial_balance=0):
self._balance = initial_balance
self._transactions = [Transaction('initial', initial_balance)]
def deposit(self, amount):
self._balance += amount
self._transactions.append(Transaction('deposit', amount))
def withdraw(self, amount):
self._balance -= amount
self._transactions.append(Transaction('withdrawal', amount))
def get_transactions(self):
return self._transactions
System Test Example (cont’d)
28 # test_bank_account.py
29 class WhenDepositingToBankAccount(BaseTestCase):
30
31
# Arrange
32
@classmethod
33
def configure(cls):
34
cls.bank_account = BankAccount(100.0)
35
36
# Act
37
@classmethod
38
def execute(cls):
39
cls.bank_account.deposit(20.0)
40
cls.bank_account.deposit(25.0)
41
cls.bank_account.withdrawal(10.0)
42
cls.bank_account.withdrawal(5.0)
43
cls.transactions = cls.bank_account.get_transactions()
44
45
# Assert
46
def should_have_transactions(self):
47
self.assertEqual(len(self.transactions), 5)
Acceptance Testing
•

Fulfill user stories

•

Can be written and/or manual

•

Could be written by someone other than
developer - stakeholder

•

Full stack

•

Run against staging environment
Acceptance Testing
Frameworks
•

https://pypi.python.org/pypi/behave

•

http://robotframework.org/

•

A few more found here:
https://wiki.python.org/moin/PythonTestingToolsT
axonomy#Acceptance.2FBusiness_Logic_Testin
g_Tools

Weitere ähnliche Inhalte

Was ist angesagt?

Continuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatlingContinuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatlingTim van Eijndhoven
 
PowerShell Functions
PowerShell FunctionsPowerShell Functions
PowerShell Functionsmikepfeiffer
 
Testing JavaScript
Testing JavaScriptTesting JavaScript
Testing JavaScriptdhtml
 
UXD Practicum - eMagine Point of Sale
UXD Practicum -  eMagine Point of SaleUXD Practicum -  eMagine Point of Sale
UXD Practicum - eMagine Point of Salewillpagan
 
Implementing Blackbox Testing
Implementing Blackbox TestingImplementing Blackbox Testing
Implementing Blackbox TestingEdureka!
 
Introduction to software testing
Introduction to software testingIntroduction to software testing
Introduction to software testingAbhishek Saxena
 
Pluses and minuses of retesting
Pluses and minuses of retestingPluses and minuses of retesting
Pluses and minuses of retestingQATestLab
 
Automate test, tools, advantages, and disadvantages
Automate test, tools, advantages,  and disadvantagesAutomate test, tools, advantages,  and disadvantages
Automate test, tools, advantages, and disadvantagesMajid Hosseini
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureA. S. M. Shafi
 
Tibco business events (be) online training institute
Tibco business events (be) online training instituteTibco business events (be) online training institute
Tibco business events (be) online training instituteMindmajix Technologies
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testingMani Kanth
 
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...Process State vs. Object State: Modeling Best Practices for Simple Workflows ...
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...Thorsten Franz
 
EasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool IntroductionEasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool IntroductionZhu Zhong
 

Was ist angesagt? (19)

Automation using ibm rft
Automation using ibm rftAutomation using ibm rft
Automation using ibm rft
 
Continuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatlingContinuous performance: Load testing for developers with gatling
Continuous performance: Load testing for developers with gatling
 
PowerShell Functions
PowerShell FunctionsPowerShell Functions
PowerShell Functions
 
Rft courseware
Rft coursewareRft courseware
Rft courseware
 
Testing JavaScript
Testing JavaScriptTesting JavaScript
Testing JavaScript
 
UXD Practicum - eMagine Point of Sale
UXD Practicum -  eMagine Point of SaleUXD Practicum -  eMagine Point of Sale
UXD Practicum - eMagine Point of Sale
 
Implementing Blackbox Testing
Implementing Blackbox TestingImplementing Blackbox Testing
Implementing Blackbox Testing
 
Introduction to software testing
Introduction to software testingIntroduction to software testing
Introduction to software testing
 
Pluses and minuses of retesting
Pluses and minuses of retestingPluses and minuses of retesting
Pluses and minuses of retesting
 
Automate test, tools, advantages, and disadvantages
Automate test, tools, advantages,  and disadvantagesAutomate test, tools, advantages,  and disadvantages
Automate test, tools, advantages, and disadvantages
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
BDD
BDDBDD
BDD
 
Tibco business events (be) online training institute
Tibco business events (be) online training instituteTibco business events (be) online training institute
Tibco business events (be) online training institute
 
Equivalence class testing
Equivalence  class testingEquivalence  class testing
Equivalence class testing
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...Process State vs. Object State: Modeling Best Practices for Simple Workflows ...
Process State vs. Object State: Modeling Best Practices for Simple Workflows ...
 
Automation testing
Automation testingAutomation testing
Automation testing
 
EasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool IntroductionEasyTest Test Automation Tool Introduction
EasyTest Test Automation Tool Introduction
 

Andere mochten auch

Objective-C for Java Developers
Objective-C for Java DevelopersObjective-C for Java Developers
Objective-C for Java DevelopersBob McCune
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Abdul Hannan
 
파이썬+클래스+구조+이해하기 20160310
파이썬+클래스+구조+이해하기 20160310파이썬+클래스+구조+이해하기 20160310
파이썬+클래스+구조+이해하기 20160310Yong Joon Moon
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldabaux singapore
 

Andere mochten auch (6)

Objective-C for Java Developers
Objective-C for Java DevelopersObjective-C for Java Developers
Objective-C for Java Developers
 
Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual Object Oriented Programming Lab Manual
Object Oriented Programming Lab Manual
 
파이썬+클래스+구조+이해하기 20160310
파이썬+클래스+구조+이해하기 20160310파이썬+클래스+구조+이해하기 20160310
파이썬+클래스+구조+이해하기 20160310
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika AldabaLightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
Lightning Talk #9: How UX and Data Storytelling Can Shape Policy by Mika Aldaba
 
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job? Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
Succession “Losers”: What Happens to Executives Passed Over for the CEO Job?
 

Ähnlich wie Testing

Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Howsatesgoral
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Frédéric Delorme
 
Building unit tests correctly with visual studio 2013
Building unit tests correctly with visual studio 2013Building unit tests correctly with visual studio 2013
Building unit tests correctly with visual studio 2013Dror Helper
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test communityKerry Buckley
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsHonza Král
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development IntroductionNguyen Hai
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Fwdays
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flexmichael.labriola
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)Rob Hale
 
Frozen rails 2012 - Fighting Code Smells
Frozen rails 2012 - Fighting Code SmellsFrozen rails 2012 - Fighting Code Smells
Frozen rails 2012 - Fighting Code SmellsDennis Ushakov
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinSigma Software
 
Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Seleniumelliando dias
 

Ähnlich wie Testing (20)

Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
 
Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8Bdd for-dso-1227123516572504-8
Bdd for-dso-1227123516572504-8
 
Building unit tests correctly with visual studio 2013
Building unit tests correctly with visual studio 2013Building unit tests correctly with visual studio 2013
Building unit tests correctly with visual studio 2013
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Tdd for BT E2E test community
Tdd for BT E2E test communityTdd for BT E2E test community
Tdd for BT E2E test community
 
TDD, BDD and mocks
TDD, BDD and mocksTDD, BDD and mocks
TDD, BDD and mocks
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Why unit testingl
Why unit testinglWhy unit testingl
Why unit testingl
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
TDD
TDDTDD
TDD
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
Test Driven Development Introduction
Test Driven Development IntroductionTest Driven Development Introduction
Test Driven Development Introduction
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in FlexassertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
assertYourself - Breaking the Theories and Assumptions of Unit Testing in Flex
 
VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)VT.NET 20160411: An Intro to Test Driven Development (TDD)
VT.NET 20160411: An Intro to Test Driven Development (TDD)
 
Getting Started With Testing
Getting Started With TestingGetting Started With Testing
Getting Started With Testing
 
Frozen rails 2012 - Fighting Code Smells
Frozen rails 2012 - Fighting Code SmellsFrozen rails 2012 - Fighting Code Smells
Frozen rails 2012 - Fighting Code Smells
 
Testing in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita GalkinTesting in FrontEnd World by Nikita Galkin
Testing in FrontEnd World by Nikita Galkin
 
Acceptance Testing With Selenium
Acceptance Testing With SeleniumAcceptance Testing With Selenium
Acceptance Testing With Selenium
 

Kürzlich hochgeladen

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 

Kürzlich hochgeladen (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

Testing

  • 2. What I Mean by Testing? • Automatic and repeatable checking that code written works as expected. • • Correct side effects • • Correct result Speedy enough Writing tests prior to writing code
  • 3. Why Test? • Reduce regression bugs • Increase code quality • • • Better design Find problems early Helps you know when you are done coding
  • 5. Unit Testing • Testing small units • Test all cases / scenarios • Mock / Patch external calls
  • 6. Unit Test Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 # transaction.py class Transaction(object): def __init__(self, action, amount): self.action = action self.amount = amount # bank_account.py class BankAccount(object): def __init__(self, initial_balance=0): self.balance = initial_balance self.transactions = [Transaction('initial', initial_balance)]
  • 7. Unit Test Example (cont'd) 17 # test_bank_account.py 18 class DescribeBankAccount(BaseTestCase): 19 20 # Arrange 21 @classmethod 22 def configure(cls): 23 cls.init_balance = 10.0 24 cls.transaction = cls.create_patch('bank_account.Transaction') 25 26 # Act 27 @classmethod 28 def execute(cls): 29 cls.bank_account = BankAccount(cls.init_balance) 30 31 # Assert 32 def should_have_balance(self): 33 self.assertEqual(self.bank_account.balance, self.init_balance) 34 35 def should_create_transaction(self): 36 self.transaction.assert_called_once_with('initial', self.init_balance) 37 38 def should_have_transactions(self): 39 self.assertEqual( 40 self.bank_account.transactions, [self.transaction.return_value])
  • 8. Integration Testing • Test interaction with dependencies / external calls • Not as detailed as unit tests - no need to test every scenario • Minimal mocking / patching
  • 9. Integration Test Example 17 # test_bank_account.py 18 class DescribeBankAccount(BaseTestCase): 19 20 # Arrange 21 @classmethod 22 def configure(cls): 23 cls.init_balance = 10.0 24 25 # Act 26 @classmethod 27 def execute(cls): 28 cls.bank_account = BankAccount(cls.init_balance) 29 30 # Assert 31 def should_have_transactions(self): 32 self.assertEqual( 33 self.bank_account.transactions, 34 [Transaction('initial', self.init_balance)], 35 )
  • 10. System / End-to-End Testing • Test public endpoints • Use full stack • No mocking / patching • Minimal to no inspecting of underlying side effects - only results of calls • Run in a staging environment
  • 11. System Test Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 # transaction.py class Transaction(object): def __init__(self, action, amount): self.action = action self.amount = amount # bank_account.py class BankAccount(object): def __init__(self, initial_balance=0): self._balance = initial_balance self._transactions = [Transaction('initial', initial_balance)] def deposit(self, amount): self._balance += amount self._transactions.append(Transaction('deposit', amount)) def withdraw(self, amount): self._balance -= amount self._transactions.append(Transaction('withdrawal', amount)) def get_transactions(self): return self._transactions
  • 12. System Test Example (cont’d) 28 # test_bank_account.py 29 class WhenDepositingToBankAccount(BaseTestCase): 30 31 # Arrange 32 @classmethod 33 def configure(cls): 34 cls.bank_account = BankAccount(100.0) 35 36 # Act 37 @classmethod 38 def execute(cls): 39 cls.bank_account.deposit(20.0) 40 cls.bank_account.deposit(25.0) 41 cls.bank_account.withdrawal(10.0) 42 cls.bank_account.withdrawal(5.0) 43 cls.transactions = cls.bank_account.get_transactions() 44 45 # Assert 46 def should_have_transactions(self): 47 self.assertEqual(len(self.transactions), 5)
  • 13. Acceptance Testing • Fulfill user stories • Can be written and/or manual • Could be written by someone other than developer - stakeholder • Full stack • Run against staging environment
  • 14. Acceptance Testing Frameworks • https://pypi.python.org/pypi/behave • http://robotframework.org/ • A few more found here: https://wiki.python.org/moin/PythonTestingToolsT axonomy#Acceptance.2FBusiness_Logic_Testin g_Tools

Hinweis der Redaktion

  1. Result – inputs -> outputs Side Effects – Car model -> start engine -> update boolean engine running Speedy – app needing 1000 calls per second Tests prior – instead of throwing together tests at the end – plan ahead
  2. Regression – knowing previous code won’t brake Design – break up code into small pieces Done coding – good design == confidence
  3. Unit – small units – possibly mocking out external dependencies Integration – testing units with their dependencies to make sure interactions work System – Calling only public API endpoints/functions and using the full stack Acceptance – automated based on user stories – could be written by someone other than developer - or just manual user testing
  4. BaseTestCase - built on top of unittest
  5. Generally would have API calls for a system running on a staging environment, but this I hope still shows the difference