advertisement

Testing

38 %
63 %
advertisement
Information about Testing
Technology

Published on March 8, 2014

Author: wcw000

Source: slideshare.net

advertisement

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

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

testing.de

Hier präsentieren wir Ihnen unsere Einzelkataloge für die entsprechenden Kategorien:
Read more

dict.cc | testing | Wörterbuch Englisch-Deutsch

Übersetzung für testing im Englisch-Deutsch-Wörterbuch dict.cc.
Read more

Platform to Create Organizational Testing and Certifications

Test.com is a software solution for you to easily create, administer and manage training courses and certification tests, in up to 22 languages.
Read more

Applause: Testing für Apps & Webseiten

Applause vereint Software Testing Tools & Services für ein Höchstmaß an Qualität im Web, auf mobilen Geräten und auf Wearables.
Read more

dict.cc Wörterbuch :: testing :: Deutsch-Englisch-Übersetzung

Englisch-Deutsch-Übersetzung für testing im Online-Wörterbuch dict.cc (Deutschwörterbuch).
Read more

DebianTesting - Debian Wiki

Debian testing is the current development state of the next stable Debian distribution. It is also made available under the code name of the next stable ...
Read more

Testing - definition of testing by The Free Dictionary

By way of testing whether there were still a living germ in such ancient seeds, Holgrave had planted some of them; and the result of his experiment was a ...
Read more

Product Testing Services | TÜV SÜD

TÜV SÜD provides internationally-accredited independent product testing services in accordance with international standards. Through a global network of ...
Read more

PHPUnit – The PHP Testing Framework

Welcome to PHPUnit! PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
Read more

Oxford English Testing - Young Learners Placement Test

Oxford Online Placement Test; Young Learners Placement Test; Exam Practice Tests for Cambridge English Key, Preliminary, First, Advanced; IELTS; TOEIC ...
Read more