SlideShare a Scribd company logo
Integration Testing
By
1.Samson Legesse
2.Tsegabrehan Zerihun
3.Teklerufael Kebebe
4.Mesele Mehamad
Object Oriented Software
Development
2
3
4
Integration
• Integration: Combining 2 or more software units
– Often a subset of the overall project (!= system testing)
• Why do software engineers care about integration?
– New problems will inevitably surface
• many systems now together that have never been before
– If done poorly, all problems present themselves at once
• hard to diagnose, debug, fix
– Cascade of interdependencies
• cannot find and solve problems one-at-a-time
5
Phased integration
• phased ("big-bang") integration:
– design, code, test, debug each class/unit/subsystem separately
– combine them all
– pray
6
Incremental integration
• Incremental integration:
– develop a functional "skeleton" system (i.e. ZFR)
– design, code, test, debug a small new piece
– integrate this piece with the skeleton
• test/debug it before adding any other pieces
7
Benefits of incremental
• Benefits:
– Errors easier to isolate, find, fix
• reduces developer bug-fixing load
– System is always in a (relatively) working state
• good for customer relations, developer morale
• Drawbacks:
– May need to create "stub" versions of some features that have
not yet been integrated
8
Top-down integration
• Top-down integration:
Start with outer UI layers and work inward
– must write (lots of) stub lower layers for UI to interact with
– allows postponing tough design/debugging decisions (bad?)
9
Bottom-up integration
• Bottom-up integration:
Start with low-level data/logic layers and work outward
– must write test drivers to run these layers
– won't discover high-level / UI design flaws until late
10
"Sandwich" integration
• “Sandwich" integration:
Connect top-level UI with crucial bottom-level classes
– add middle layers later as needed
– more practical than top-down or bottom-up?
11
Daily builds
• Daily build: Compile working executable on a daily basis
– allows you to test the quality of your integration so far
– helps morale; product "works every day"; visible progress
– best done automated or through an easy script
– quickly catches/exposes any bug that breaks the build
• Smoke test: A quick set of tests run on the daily build.
– NOT exhaustive; just sees whether code "smokes" (breaks)
– used (along with compilation) to make sure daily build runs
• Continuous integration:
Adding new units immediately as they are written.
12
13
Integration testing
• Integration testing: Verifying software quality by testing two
or more dependent software modules as a group.
• Challenges:
– Combined units can fail
in more places and in more
complicated ways.
– How to test a partial system
where not all parts exist?
– How to "rig" the behavior of
unit A so as to produce a
given behavior from unit B?
14
Stubs
• Stub: A controllable replacement for an existing software unit
to which your code under test has a dependency.
– useful for simulating difficult-to-control elements:
• network / internet
• database
• time/date-sensitive code
• files
• threads
• memory
– also useful when dealing with brittle legacy code/systems
15
Create a stub, step 1
• Identify the external dependency.
– This is either a resource or a class/object.
– If it isn't an object, wrap it up into one.
• (Suppose that Class A depends on troublesome Class B.)
16
Create a stub, step 2
• Extract the core functionality of the object into an interface.
– Create an InterfaceB based on B
– Change all of A's code to work with type InterfaceB, not B
17
Create a stub, step 3
• Write a second "stub" class that also implements the interface,
but returns pre-determined fake data.
– Now A's dependency on B is dodged and can be tested easily.
– Can focus on how well A integrates with B's external behavior.
18
Injecting a stub
• Seams: Places to inject the stub so Class A will talk to it.
– at construction (not ideal)
A aardvark = new A(new StubB());
– through a getter/setter method (better)
A apple = new A(...);
aardvark.setResource(new StubB());
– just before usage, as a parameter (also better)
aardvark.methodThatUsesB(new StubB());
• You should not have to change A's code everywhere (beyond using
your interface) in order to use your Stub B. (a "testable design")
19
"Mock" objects
• Mock object: A fake object that decides whether a unit test
has passed or failed by watching interactions between objects.
– useful for interaction testing (as opposed to state testing)
20
Stubs vs. Mocks
– A stub gives out data that goes to
the object/class under test.
– The unit test directly asserts against
class under test, to make sure it gives
the right result when fed this data.
– A mock waits to be called by
the class under test (A).
• Maybe it has several methods
it expects that A should call.
– It makes sure that it was contacted
in exactly the right way.
• If A interacts with B the way it should, the test passes.
21
Mock object Frameworks
• Stubs are often best created by hand/IDE.
Mocks are tedious to create manually.
• Mock object frameworks help with the process.
– android-mock, EasyMock, jMock (Java)
– FlexMock / Mocha (Ruby)
– SimpleTest / PHPUnit (PHP)
– ...
• Frameworks provide the following:
– auto-generation of mock objects that implement a given interface
– logging of what calls are performed on the mock objects
– methods/primitives for declaring and asserting your expectations
22
A jMock mock object
import org.jmock.integration.junit4.*; // Assumes that we are testing
import org.jmock.*; // class A's calls on B.
@RunWith(JMock.class)
public class ClassATest {
private Mockery mockery = new JUnit4Mockery(); // initialize jMock
@Test public void testACallsBProperly1() {
// create mock object to mock InterfaceB
final InterfaceB mockB = mockery.mock(InterfaceB.class);
// construct object from class under test; attach to mock
A aardvark = new A(...);
aardvark.setResource(mockB);
// declare expectations for how mock should be used
mockery.checking(new Expectations() {{
oneOf(mockB).method1("an expected parameter");
will(returnValue(0.0));
oneOf(mockB).method2();
}});
// execute code A under test; should lead to calls on mockB
aardvark.methodThatUsesB();
// assert that A behaved as expected
mockery.assertIsSatisfied();
}
}
23
jMock API
• jMock has a strange API based on "Hamcrest" testing syntax.
• Specifying objects and calls:
– oneOf(mock), exactly(count).of(mock),
– atLeast(count).of(mock), atMost(count).of(mock),
– between(min, max).of(mock)
– allowing(mock), never(mock)
• The above accept a mock object and return a descriptor that you can
call methods on, as a way of saying that you demand that those
methods be called by the class under test.
– atLeast(3).of(mockB).method1();
• "I expect that method1 will be called on mockB 3 times here."
24
Expected actions
• .will(action)
– actions: returnValue(v), throwException(e)
• values:
– equal(value), same(value), any(type), aNull(type),
aNonNull(type), not(value), anyOf(value1, ..,valueN)
– oneOf(mockB).method1();
will(returnValue(anyOf(1, 4, -3)));
• "I expect that method1 will be called on mockB once here, and that
it will return either 1, 4, or -3."
25
Using stubs/mocks together
• Suppose a log analyzer reads from a web service.
If the web fails to log an error, the analyzer must send email.
– How to test to ensure that this behavior is occurring?
• Set up a stub for the web service that intentionally fails.
• Set up a mock for the email service that checks to see
whether the analyzer contacts it to send an email message.
26
27
28
END
Thank you

More Related Content

What's hot

Writing good unit test
Writing good unit testWriting good unit test
Writing good unit test
Lucy Lu
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
alessiopace
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)Foyzul Karim
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
David Noble
 
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
Sigma Software
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
Dave Bouwman
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
Paul Blundell
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
Seb Rose
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
Alexander Goida
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
Francesco Garavaglia
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 Proxy
Alexandr Skachkov
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
Hong Le Van
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing FundamentalsRichard Paul
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
Deepak Singhvi
 
Writing useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you buildWriting useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you build
Andrei Sebastian Cîmpean
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
JWORKS powered by Ordina
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
Pavlo Hodysh
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
sgleadow
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
Noam Kfir
 
Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)
jaxLondonConference
 

What's hot (20)

Writing good unit test
Writing good unit testWriting good unit test
Writing good unit test
 
Embrace Unit Testing
Embrace Unit TestingEmbrace Unit Testing
Embrace Unit Testing
 
Unit testing (workshop)
Unit testing (workshop)Unit testing (workshop)
Unit testing (workshop)
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
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
 
Unit Testing 101
Unit Testing 101Unit Testing 101
Unit Testing 101
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Applying TDD to Legacy Code
Applying TDD to Legacy CodeApplying TDD to Legacy Code
Applying TDD to Legacy Code
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
JavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 ProxyJavaScript Metaprogramming with ES 2015 Proxy
JavaScript Metaprogramming with ES 2015 Proxy
 
Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++Test driven development and unit testing with examples in C++
Test driven development and unit testing with examples in C++
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.Testing and Mocking Object - The Art of Mocking.
Testing and Mocking Object - The Art of Mocking.
 
Writing useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you buildWriting useful automated tests for the single page applications you build
Writing useful automated tests for the single page applications you build
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Unit & integration testing
Unit & integration testingUnit & integration testing
Unit & integration testing
 
iOS Unit Testing
iOS Unit TestingiOS Unit Testing
iOS Unit Testing
 
TDD and the Legacy Code Black Hole
TDD and the Legacy Code Black HoleTDD and the Legacy Code Black Hole
TDD and the Legacy Code Black Hole
 
Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)Java Testing With Spock - Ken Sipe (Trexin Consulting)
Java Testing With Spock - Ken Sipe (Trexin Consulting)
 

Similar to Integration testing

Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
Rody Middelkoop
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptx
skknowledge
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
Sergey Podolsky
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
Ortus Solutions, Corp
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
Fwdays
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
Lilia Sfaxi
 
Implementing Quality on a Java Project
Implementing Quality on a Java ProjectImplementing Quality on a Java Project
Implementing Quality on a Java Project
Vincent Massol
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
Martin Sykora
 
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
Dror Helper
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
NexThoughts Technologies
 
Unit testing
Unit testingUnit testing
Testing – With Mock Objects
Testing – With Mock ObjectsTesting – With Mock Objects
Testing – With Mock Objects
emmettwalsh
 
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
DevDay.org
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
Thierry Gayet
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
Andrea Paciolla
 
Devday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvuDevday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvu
Phat VU
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4Billie Berzinskas
 
Unit testing and mocking in Python - PyCon 2018 - Kenya
Unit testing and mocking in Python - PyCon 2018 - KenyaUnit testing and mocking in Python - PyCon 2018 - Kenya
Unit testing and mocking in Python - PyCon 2018 - Kenya
Erick M'bwana
 

Similar to Integration testing (20)

Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptx
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!CBDW2014 - MockBox, get ready to mock your socks off!
CBDW2014 - MockBox, get ready to mock your socks off!
 
Unit testing basic
Unit testing basicUnit testing basic
Unit testing basic
 
Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"Никита Галкин "Testing in Frontend World"
Никита Галкин "Testing in Frontend World"
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Implementing Quality on a Java Project
Implementing Quality on a Java ProjectImplementing Quality on a Java Project
Implementing Quality on a Java Project
 
Testing & should i do it
Testing & should i do itTesting & should i do it
Testing & should i do it
 
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 test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Unit testing
Unit testingUnit testing
Unit testing
 
Testing – With Mock Objects
Testing – With Mock ObjectsTesting – With Mock Objects
Testing – With Mock Objects
 
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
[DevDay 2016] Real Unit Testing with mocking framework - Speaker: Phat Vu – S...
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
Javascript tdd byandreapaciolla
Javascript tdd byandreapaciollaJavascript tdd byandreapaciolla
Javascript tdd byandreapaciolla
 
Devday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvuDevday2016 real unittestingwithmockframework-phatvu
Devday2016 real unittestingwithmockframework-phatvu
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
Coldbox developer training – session 4
Coldbox developer training – session 4Coldbox developer training – session 4
Coldbox developer training – session 4
 
Unit testing and mocking in Python - PyCon 2018 - Kenya
Unit testing and mocking in Python - PyCon 2018 - KenyaUnit testing and mocking in Python - PyCon 2018 - Kenya
Unit testing and mocking in Python - PyCon 2018 - Kenya
 

Recently uploaded

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 

Recently uploaded (20)

Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 

Integration testing

  • 1. Integration Testing By 1.Samson Legesse 2.Tsegabrehan Zerihun 3.Teklerufael Kebebe 4.Mesele Mehamad Object Oriented Software Development
  • 2. 2
  • 3. 3
  • 4. 4 Integration • Integration: Combining 2 or more software units – Often a subset of the overall project (!= system testing) • Why do software engineers care about integration? – New problems will inevitably surface • many systems now together that have never been before – If done poorly, all problems present themselves at once • hard to diagnose, debug, fix – Cascade of interdependencies • cannot find and solve problems one-at-a-time
  • 5. 5 Phased integration • phased ("big-bang") integration: – design, code, test, debug each class/unit/subsystem separately – combine them all – pray
  • 6. 6 Incremental integration • Incremental integration: – develop a functional "skeleton" system (i.e. ZFR) – design, code, test, debug a small new piece – integrate this piece with the skeleton • test/debug it before adding any other pieces
  • 7. 7 Benefits of incremental • Benefits: – Errors easier to isolate, find, fix • reduces developer bug-fixing load – System is always in a (relatively) working state • good for customer relations, developer morale • Drawbacks: – May need to create "stub" versions of some features that have not yet been integrated
  • 8. 8 Top-down integration • Top-down integration: Start with outer UI layers and work inward – must write (lots of) stub lower layers for UI to interact with – allows postponing tough design/debugging decisions (bad?)
  • 9. 9 Bottom-up integration • Bottom-up integration: Start with low-level data/logic layers and work outward – must write test drivers to run these layers – won't discover high-level / UI design flaws until late
  • 10. 10 "Sandwich" integration • “Sandwich" integration: Connect top-level UI with crucial bottom-level classes – add middle layers later as needed – more practical than top-down or bottom-up?
  • 11. 11 Daily builds • Daily build: Compile working executable on a daily basis – allows you to test the quality of your integration so far – helps morale; product "works every day"; visible progress – best done automated or through an easy script – quickly catches/exposes any bug that breaks the build • Smoke test: A quick set of tests run on the daily build. – NOT exhaustive; just sees whether code "smokes" (breaks) – used (along with compilation) to make sure daily build runs • Continuous integration: Adding new units immediately as they are written.
  • 12. 12
  • 13. 13 Integration testing • Integration testing: Verifying software quality by testing two or more dependent software modules as a group. • Challenges: – Combined units can fail in more places and in more complicated ways. – How to test a partial system where not all parts exist? – How to "rig" the behavior of unit A so as to produce a given behavior from unit B?
  • 14. 14 Stubs • Stub: A controllable replacement for an existing software unit to which your code under test has a dependency. – useful for simulating difficult-to-control elements: • network / internet • database • time/date-sensitive code • files • threads • memory – also useful when dealing with brittle legacy code/systems
  • 15. 15 Create a stub, step 1 • Identify the external dependency. – This is either a resource or a class/object. – If it isn't an object, wrap it up into one. • (Suppose that Class A depends on troublesome Class B.)
  • 16. 16 Create a stub, step 2 • Extract the core functionality of the object into an interface. – Create an InterfaceB based on B – Change all of A's code to work with type InterfaceB, not B
  • 17. 17 Create a stub, step 3 • Write a second "stub" class that also implements the interface, but returns pre-determined fake data. – Now A's dependency on B is dodged and can be tested easily. – Can focus on how well A integrates with B's external behavior.
  • 18. 18 Injecting a stub • Seams: Places to inject the stub so Class A will talk to it. – at construction (not ideal) A aardvark = new A(new StubB()); – through a getter/setter method (better) A apple = new A(...); aardvark.setResource(new StubB()); – just before usage, as a parameter (also better) aardvark.methodThatUsesB(new StubB()); • You should not have to change A's code everywhere (beyond using your interface) in order to use your Stub B. (a "testable design")
  • 19. 19 "Mock" objects • Mock object: A fake object that decides whether a unit test has passed or failed by watching interactions between objects. – useful for interaction testing (as opposed to state testing)
  • 20. 20 Stubs vs. Mocks – A stub gives out data that goes to the object/class under test. – The unit test directly asserts against class under test, to make sure it gives the right result when fed this data. – A mock waits to be called by the class under test (A). • Maybe it has several methods it expects that A should call. – It makes sure that it was contacted in exactly the right way. • If A interacts with B the way it should, the test passes.
  • 21. 21 Mock object Frameworks • Stubs are often best created by hand/IDE. Mocks are tedious to create manually. • Mock object frameworks help with the process. – android-mock, EasyMock, jMock (Java) – FlexMock / Mocha (Ruby) – SimpleTest / PHPUnit (PHP) – ... • Frameworks provide the following: – auto-generation of mock objects that implement a given interface – logging of what calls are performed on the mock objects – methods/primitives for declaring and asserting your expectations
  • 22. 22 A jMock mock object import org.jmock.integration.junit4.*; // Assumes that we are testing import org.jmock.*; // class A's calls on B. @RunWith(JMock.class) public class ClassATest { private Mockery mockery = new JUnit4Mockery(); // initialize jMock @Test public void testACallsBProperly1() { // create mock object to mock InterfaceB final InterfaceB mockB = mockery.mock(InterfaceB.class); // construct object from class under test; attach to mock A aardvark = new A(...); aardvark.setResource(mockB); // declare expectations for how mock should be used mockery.checking(new Expectations() {{ oneOf(mockB).method1("an expected parameter"); will(returnValue(0.0)); oneOf(mockB).method2(); }}); // execute code A under test; should lead to calls on mockB aardvark.methodThatUsesB(); // assert that A behaved as expected mockery.assertIsSatisfied(); } }
  • 23. 23 jMock API • jMock has a strange API based on "Hamcrest" testing syntax. • Specifying objects and calls: – oneOf(mock), exactly(count).of(mock), – atLeast(count).of(mock), atMost(count).of(mock), – between(min, max).of(mock) – allowing(mock), never(mock) • The above accept a mock object and return a descriptor that you can call methods on, as a way of saying that you demand that those methods be called by the class under test. – atLeast(3).of(mockB).method1(); • "I expect that method1 will be called on mockB 3 times here."
  • 24. 24 Expected actions • .will(action) – actions: returnValue(v), throwException(e) • values: – equal(value), same(value), any(type), aNull(type), aNonNull(type), not(value), anyOf(value1, ..,valueN) – oneOf(mockB).method1(); will(returnValue(anyOf(1, 4, -3))); • "I expect that method1 will be called on mockB once here, and that it will return either 1, 4, or -3."
  • 25. 25 Using stubs/mocks together • Suppose a log analyzer reads from a web service. If the web fails to log an error, the analyzer must send email. – How to test to ensure that this behavior is occurring? • Set up a stub for the web service that intentionally fails. • Set up a mock for the email service that checks to see whether the analyzer contacts it to send an email message.
  • 26. 26
  • 27. 27