Years after Kent Beck provided JUnit, unit testing is part of most developer teams tooling. However, there’s a trend that tends to threaten unit testing, claiming only integration testing can truly detects defects in software. In this talk, we will first define what unit testing and integration testing are, and their respective pros, cons and uses. Then, we will have a look at the unique challenges posed by integration testing. Finally, tools and techniques will be presented to somewhat remedy to that so that integration testing becomes a true asset in each software developer bag of tricks.
7. @nicolas_frankel
UNIT VS. INTEGRATION TESTING
● Unit Testing
○ Testing a unit in isolation
● Integration Testing
○ Testing the collaboration
of multiple units
11. @nicolas_frankel
UNIT + INTEGRATION TESTING
● Take a prototype car on a test
drive having tested only nuts and
bolts?
● Manufacture a car having tested
nuts and bolts but without having
tested it on numerous test
drives?
21. @nicolas_frankel
INTEGRATION TESTS ARE STILL SLOW
● Separating IT doesn’t make
them faster
● But errors can be
uncovered faster
○ Fail fast
○ It will speed testing
34. @nicolas_frankel
ORACLE DATABASE USE-CASE
● Use an in-memory data source
and hope for the best
● Use Oracle Express and hope for
the best
● Use a dedicated remote schema
for each developer
○ And your DBAs will hate you
36. @nicolas_frankel
MANAGING THE GAP RISK
● In-memory databases are
easy to setup
● h2 is such a database
○ Compatibility modes for
most widespread DB
○ jdbc:h2:mem:test;
MODE=Oracle
37. @nicolas_frankel
WEB SERVICES: COPING WITH FRAGILITY
● Web Services as infrastructure
resources
○ Hosted on-site
○ Or outside
● Different architectures
○ REST(ful)
○ SOAP
44. @nicolas_frankel
SOAPUI USAGE
● Get WSDL
○ Either online
○ Or from a file
● Create MockService
○ Craft the adequate response
● Run the service
● Point the dependency to
localhost
45. @nicolas_frankel
CHALLENGES TO THE PREVIOUS SCENARIO
● Craft the adequate response?
○ More likely get one from the
real WS
○ And tweak it
● Running in an automated way
○ Save the project
○ Get the SOAPUI jar
○ Read the project and launch
47. @nicolas_frankel
FAKING WEB SERVICE IN REAL-LIFE
● Use the same rules as for UT
○ Keep validation simple
○ Test one thing
● Keep setup simple
○ Don’t put complex logic
○ OK to duplicate setup in each
test
■ Up to a point
Author:I,rolfB
56. @nicolas_frankel
TIPS
● Prevent coupling
○ Use top-level assembly instead
of fragment references
● Pool exhaustion check
○ Set the maximum number of
connections in the pool to 1
● Compile-time safety
○ Use JavaConfig
69. @nicolas_frankel
THE JAVA EE WORLD
● Java EE has unique
challenges
○ CDI has no explicit
wiring
○ Different application
servers
70. @nicolas_frankel
DEPLOY ONLY WHAT YOU WANT
● Standalone API to deploy only
resources relevant to the test
○ Just pick and choose
● Maven Integration
○ Gradle too…