Introduction to BP Ship Terminal Feedback integration with ...
Integration testing - A&BP CC
-
Upload
jworks-powered-by-ordina -
Category
Education
-
view
394 -
download
0
Transcript of Integration testing - A&BP CC
Integration TestingAwesome subtitle
Integration TestingAwesome subtitle
Integration TestingAwesome subtitle
Integration TestingAwesome subtitle
Testing
▪ Unit testing▪ Integration testing▪ System Integration testing▪ Load testing▪ Performance testing▪ User acceptance testing
Overview
1. Testing Terminologies
2. Component Integration Testing
a. Persistence tests
b. Container tests
c. Other component integrations
3. System Integration Testing
Testing terminologies
Test levels/phases
Requirement Specification Acceptance Testing
Functional Analysis System Testing
Technical Design Integration Testing
Coding Component Testing
System Integration Testing
Component Integration Testing
BB
WB
Test characteristics
▪ Connectivity▪ Continuity▪ Data controllability▪ Effectivity▪ Efficiency▪ Flexibility▪ Functionality▪ Suitability of infrastructure▪ Maintainability▪ Manageability▪ Performance▪ Portability▪ Reusability▪ Security▪ Suitability▪ Testability▪ User-friendliness
Focus on terminology
▪ Dedicated test environments
▪ Sanity tests (smoke tests)
▪ Regression testing
▪ Combinations and boundaries
▪ Positive and negative
▪ Valid and invalid
▪ End 2 End testing (chain testing)
▪ Performance testing (load testing vs. stress testing)
▪ Manual testing vs. test automation
Component Integration Testing
Component Integration Testing
Demo:▪ Service Layer going to Database Layer
PERSISTENCE TESTS
Persistence Tests
Using real databases for tests:▪ slow▪ harder than it should be▪ separate schemas per user?▪ network required
Using local database for tests:▪ even slower▪ requires (annoying) installation▪ no network required
Persistence Tests
Using in-memory database for tests:▪ super fast▪ only lives during test▪ allows for very specific test data▪ can be upgraded/changed/...
Persistence Tests
Demo:▪ JPA2 via Hibernate▪ Spring Data▪ SpringJUnit4ClassRunner▪ DBUnit
Persistence Tests
Demo:▪ JPA2 via Hibernate▪ Spring Data▪ SpringJUnit4ClassRunner▪ DBUnit▪ + Spring MVC (REST client)▪ + Selenium (Chrome WebDriver)
CONTAINER TESTS
What is a container?
What is a container?
A Java ecosystem in which an application is managed
life-cycletransactionspersistencesecurity...
What is a container?
DI container (Dependency Injection)EJB container (Enterprise Java Beans)
Web containerApplication client container
Applet container
Most known providers today
Most known providers today
▪ Only provides a DI Container: IoC (inversion of control)▪ Runs anywhere▪ No application server needed
Most known providers today
Most known providers today
▪ Provides specifications for:▪ DI container: CDI (Contexts and Dependency Injection)▪ EJB container▪ Web container▪ Application client container▪ Applet container
▪ It only runs on an application server implementing these specs.
What to test?
Dependency Injection (is everything wired correctly together?)▪ Application Context
▪ CDI
What to test?
Persistence: and : is JPA (Java Persistence API) mapping correct?
What to test?
Transaction Management:▪ : Spring Transaction
▪ : JTA (Java Transaction API)
What to test?
Deployment:▪ : no deployment needed (not to test)
▪ : will it deploy without exceptions in a real Java EE container?
How?
Container-tests
How?
out of the box
@RunWith(SpringJUnit4ClassRunner.class)@SpringApplicationConfiguration(classes = Application.class)@Transactionalpublic class SpringIntegrationTest {
Really, that easy :-) !!
How?
not out of the box
Need for third-party frameworks
How?
OpenEJB: a lightweight embeddable EJB containerCan be used with JUnit
How?
A lot to write
How?
And more:
How?
Arquillian:▪ Embeddable containers for JUnit-tests▪ Run tests in real running containers
The real thing application servers:GlassfishJbossWeblogic...
How?
All it takes in Arquillian@RunWith(Arquillian.class)public class ArquillianIntegrationTest { @Deployment public static Archive<?> createDeployment() { return ShrinkWrap.create(WebArchive.class, "test.war") .addPackage(MeetingRoom.class.getPackage()) .addPackage(MeetingOrganizer.class.getPackage()) .addPackage(MeetingRoomRepository.class.getPackage()) .addAsResource("persistence-test.xml", "META-INF/persistence.xml") .addAsWebInfResource("jbossas-ds.xml") .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); }
Actually, together with xml config, but pretty straight-forward
Demo
Integration testwiringtransactional test
Integration testwiringtransactional testweb integration test with Graphene
https://github.com/brunobouko
OTHER COMPONENT INTEGRATIONS
File Permissions
How to test ?
● Via dedicated checkFilePermission fp = new FilePermission("file.txt", "read");AccessController.checkPermission(fp);
● Via shell scriptsCheck you have staff group and file is readable by staff
[~] % ls -l file.txt | awk '{ print $1" "$3" "$4;}'\ | egrep -e '....r..... .* staff' >|/dev/null && echo 'ok' || echo 'ko' ok ● Manually...
Results
Emails
How to test
● With developer controlled server● With code
○ Spring Integration: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/mail● With dedicated tools
Eg: Sending emails could use FakeSMTP - http://nilhcem.github.io/FakeSMTP● Running fake mail server during tests
○ GreenMail - http://www.icegreen.com/greenmail/
Roll the demo in: SendAMail project + GreenMailhttps://github.com/pijalu/SendAMail.git
JMS
How to test ?
● Writing test code○ ActiveMQ - http://activemq.apache.org/how-to-unit-test-jms-code.html○ Spring Integration- https://github.com/spring-projects/spring-integration-
samples/tree/master/basic/jms
● Using tools○ HermesJMS - http://www.hermesjms.com/confluence/display/HJMS/Home
■ Allows to post message on queues/topics■ Observes topics !
● With containers test enabled test like Arquillian
Roll the demo in: EJBees project with Arquillian !https://github.com/pijalu/ejbees.git
LDAP (and co)
How to test ?
● With tools○ Spring security
■ It can run a “test” LDAP server based on a LDIF file
○ Apache Directory Studio■ Allows to connect and browse to LDAP server (and AD is LDAP, but weird one...)■ Allows to run your own LDAP server for integration■ Allows to run your own LDAP server within JUnit tests
Roll the Demo in: LDAP Dance
https://github.com/pijalu/ldapdance
SOAP/REST/WS/...
How to test ?
● Writing your own integration tests● Using tools
○ SoapUI■ Can call the service■ Perform tests■ Can run with maven
Roll the demo in: SoapUI + SoapUI project !
https://github.com/pijalu/SoapUIDemo.git
Questions on other components tests ?
Environments
Environment - Disclaimer
● Commonly used● Not exact● Merged environments
Environment - Local
● typical laptop/desktop● focus on work at hand● not representative (resources, data volume)● maybe even different application server● mostly expecting unlimited resources● limited constraints● frequent deployments● possibly different os● possibly different settings (regional settings)
➔ goal: get your tasks completed➔ target users: developer
Environment - Component Integration (DEV)
● more limited within company standards● possibly increased complexity (authentication required)● automated deployment?● actual application server● possible dummy systems● mostly not load balanced
➔ goal: will it deploy on the actual infrastructure, sanity testing➔ target users: developers➔ challenge: bug free (and retard-proof)
Environment - System Integration (INT)
● representative systems● possibly reduced data● possibly load balanced● whatsup
➔ goal: does it work well combined with other systems?➔ target users: developers, testers
Environment - System Testing (TEST)
● representative systems● possibly reduced data● possibly load balanced
➔ goal: is it ready to present to business?➔ target users: testers, functional analysts➔ challenge: find the bugs!
Environment - User Acceptance Test (UAT)
● almost the real deal● no impact on end users● preferably identical setup compared to production● loadbalanced
➔ goal: does it meet the business requirements we've specified? do we need to rethink something? is this performant enough?
➔ target users: business users
Environment - Production
● the real deal● impact on end users
➔ target users: end users
Environment - Disaster Recovery
● mirror● offline● alternate site● pre go-live
System Integration Testing
System Integration Testing - What?
● web applications● desktop applications● mobile applications● embedded applications● headless applications● others?
System Integration Testing - How?
● manual testing● manual tools
○ soap ui○ db tools ○ ldap browser
● automated tools○ proprietary○ selenium○ custom made
System Integration Testing - Web application
● browser dependant● device dependant● subjective testing● subject to change
System Integration Testing - Web application
● browser dependant● device dependant● subjective testing● subject to change
System Integration Testing - Selenium
● target specific browser version● browser bugs● user simulation● reusability● screenshots
➔ record/replay◆ limited usability◆ parametrize!
➔ use static ids➔ html only
System Integration Testing - Headless browser
● faster● not 100% representative● prepare test cases● url check● javascript check● objective
➔ karma➔ jasmine
System Integration Testing - When?
● funded by project● sucky developers● regression● flow based applications
http://www.downvids.net/product-testing-institute-models-very-very-funny-hq--38051.html