SlideShare a Scribd company logo
How to Test Enterprise Java Applications
Alex Soto Bueno
Computer Engineer
World Is Changing

The World Is Changing So Fast




            {text/html}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}
            {app/json}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}
            {app/json}
            {app/xml}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}
            {app/json}
            {app/xml}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing

The World Is Changing So Fast




            {text/html}
            {app/json}
            {app/xml}




   Client   Protocol      Server   Persistence

                                                 2
World Is Changing



     Testing Frameworks are
        Changing Too



                              3
Bio




      Alex Soto Bueno

      Computer Engineer
      Diagnostic Grifols
      Compiler Tutor
      Active Blogger & Speaker
                                 4
Overview


     Unit Tests   - 80 % of code




                                   5
Overview


     Unit Tests               - 80 % of code



      Integration Tests - 15 % of code




                                               5
Overview


     Unit Tests                         - 80 % of code



      Integration Tests - 15 % of code
           Acceptance Tests - 5 % of code




                                                         5
Unit Tests

  Tests small pieces of production code




                                          6
Unit Tests

  Tests small pieces of production code

             Confidence to Change




                                          6
Unit Tests

  Tests small pieces of production code

             Confidence to Change

               Quick Feedback




                                          6
Unit Tests

  Tests small pieces of production code

             Confidence to Change

               Quick Feedback

               Documentation




                                          6
Unit Tests

   FIRST Important Rules




                           7
Unit Tests

       Fast




              8
Unit Tests

       Fast

        Resist Temptation




                            8
Unit Tests

       Isolation




                   9
Unit Tests

       Repeatable




                    10
Unit Tests

       Self-Validating




                         11
Unit Tests

       Timely




                12
Unit Tests




Different Layers - Different Frameworks




                                          13
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




                                              14
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




          code




                                              14
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




          code




       fixtures




                                              14
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




          code




       fixtures




   configuration                               14
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




          code




       fixtures
                     JSTestDriver Server




   configuration                               14
Client Side

 JS TestDriver xUnit approach to Javascript
Apache License 2.0




          code




       fixtures
                     JSTestDriver Server   browsers




   configuration                                       14
Client Side

Sinon.js mocking library for Javascript
BSD License




                                          15
Client Side

Sinon.js mocking library for Javascript
BSD License




sinon.stub(jQuery,
“ajax”).yieldsTo(“success”,’{“name”:”Alex”}’);




                                                 15
Demo




       16
Server Side

Unit Test Framework for Java
                               Common Public License




                                                       17
Server Side

Hamcrest is about expressiveness

                                   New BSD License




                                                     18
Server Side

Hamcrest is about expressiveness

                                          New BSD License




String officerRank = getRankByDate(officer);
List<String> ranks = [(“Captain”, “Commander”)];

assertEquals(true, ranks.contains(officerRank));




                                                            18
Server Side

Hamcrest is about expressiveness

                                   New BSD License




                                                     18
Server Side

Hamcrest is about expressiveness

                                          New BSD License




String officerRank = getRankByDate(officer);

assertThat(officerRank,
isOneOf(“Captain”,”Commander”));

assertThat(age, is(10));
assertThat(name, is(not(“Alex”));
assertThat(calculated, isNotANumber());
                                                            18
Server Side

Simple & Clean Mock API
                          MIT License




                                        19
Server Side

Simple & Clean Mock API
                                        MIT License



@Mock private OfficerDao officerDao;
...
MockitoAnnotations.initMocks(this);
...

when(officerDao.findOfficerByAge(22))
    .thenReturn(newOfficer);

when(officerDao.findOfficerByAge(greaterThan(50)))
    .thenThrow(new OldOfficerException());

                                                      19
Persistence Side


       RDBMS are Homogeneous

       NoSQL are Heterogeneous




                                 20
Persistence Side (SQL)

Avoid HIT   Database




                         21
Persistence Side (SQL)

Avoid HIT   Database

              In-Memory
               Databases



                           21
Persistence Side (SQL)

Avoid HIT      Database

                           In-Memory
                            Databases

      Apache License 2.0     BSD License *
                                             MPL 1.1 & EPL 1.0




                                                                 21
Persistence Side (SQL)

    Isolation problem with Database
          Insert-Delete Problem




                                      22
Persistence Side (SQL)

    Isolation problem with Database
          Insert-Delete Problem


               GNU LGPL 2.1




                                      22
Persistence Side (SQL)

    Isolation problem with Database
          Insert-Delete Problem


               GNU LGPL 2.1



         Define base data set




                                      22
Persistence Side (SQL)

          Isolation problem with Database
                Insert-Delete Problem


                     GNU LGPL 2.1



               Define base data set

@Before

DatabaseOperation.CLEAN_INSERT.execute(connection,
dataSet);
                                                 22
Persistence Side (NoSQL)




                           23
Persistence Side (NoSQL)


 GNU AGPL v3.0




        No Embedded (in-memory) Mode
        (SERVER - 1153)
        No Test Isolation Framework




                                       24
Persistence Side (NoSQL)


GPL v3 & AGPL v3




            Embedded (in-memory) Mode
            Partially supported




                                        25
Persistence Side (NoSQL)

  DBUnit for NOSQL
                      Apache License 2.0




                                           26
Persistence Side (NoSQL)

  DBUnit for NOSQL

    MongoDb
                      Apache License 2.0




    Neo4J

    CouchDb

    Cassandra



                                           26
Demo




       27
Integration Tests

  Test Collaboration Between Components




                                          28
Integration Tests

  Test Collaboration Between Components

     Database
     IO system
     Special Environment Configuration




                                          28
Integration Tests

  Common Problems in JEE 6

     CDI - @EJB, @Inject, @PersistenceContext




                                            29
Integration Tests

  Common Problems in JEE 6

     CDI - @EJB, @Inject, @PersistenceContext



     Container Lifecyle Management

     Create Deployment Archive


                                            29
Integration Tests

  Common Problems in JEE 6




                       k
                    oc
     CDI - @EJB, @Inject, @PersistenceContext




                   M
                T
     Container Lifecyle Management
           NO

     Create Deployment Archive
      Do



                                            29
Integration Tests

Arquillian brings tests to runtime

      Manage Lifecycle of Container     Apache License 2.0




  Create/Deploy MicroDeployments

              Enriching Test Classes

Run Tests Inside/Against Container

                         IDE Friendly
                                                    30
Integration Tests

Arquillian brings tests to runtime


                               ks
      Manage Lifecycle of Container
                             c
                                        Apache License 2.0




                         o
                      M Classes
 Create/Deploy MicroDeployments

             o  r e
              Enriching Test

     o   M
  N
Run Tests Inside/Against Container

                         IDE Friendly
                                                    30
Integration tests




                    31
Integration tests




                    31
Integration tests




                    31
Integration tests




                    31
Integration tests




                    31
Integration tests




                    31
Demo




       32
Acceptance Tests

  Test Customer Requirements




                               33
Acceptance Tests

  User Story

     everyday language sentence

     adds business values




                                  34
Acceptance Tests

  User Story

     everyday language sentence

     adds business values

  As administrator, I want to add new books
  to a collection, so users can borrow them



                                              34
Acceptance Tests

  Acceptance Criteria

     story completeness




                          35
Acceptance Tests

  Acceptance Criteria

      story completeness



Administrator can add new books.
Administrator can categorise books.
User can borrow books added by administrator.

                                                35
Acceptance Tests

     Concrete Examples

1. Create Lord of the Rings
Book.

2. Assign J.R.R Tolkien as
author.

3. Set Book Description.

4. Add Book to System.

5. Check that Book is shown
in screen.



                              36
Acceptance Tests




                   37
Acceptance Tests

  JEE UI is Web

     How to access to web elements




                                     37
Acceptance Tests

  JEE UI is Web

     How to access to web elements


  AT categorised by user stories

     How to organize user stories and specs



                                         37
Acceptance Tests

  Thucydides
                   Apache License 2.0




                                        38
Acceptance Tests

  Thucydides

     Selenium 2 Extension
                            Apache License 2.0




                                                 38
Acceptance Tests

  Thucydides

     Selenium 2 Extension
                                  Apache License 2.0




     Organise tests and stories




                                                       38
Acceptance Tests

  Thucydides

     Selenium 2 Extension
                                    Apache License 2.0




     Organise tests and stories

     Record/Report test execution




                                                         38
Acceptance Tests

  Thucydides

     Selenium 2 Extension
                                    Apache License 2.0




     Organise tests and stories

     Record/Report test execution

     Measure Functional Cover


                                                         38
Acceptance Tests


    Choose a user story




                          39
Acceptance Tests


    Choose a user story

      Implement PageObject/s




                               39
Acceptance Tests


    Choose a user story

      Implement PageObject/s

         Implement Test Step Library




                                       39
Acceptance Tests


    Choose a user story

      Implement PageObject/s

         Implement Test Step Library

            Implement User Story following A.C




                                                 39
Demo




       40
Continuous Integration

  Different Kind of Tests Exist




                                  41
Continuous Integration

  Different Kind of Tests Exist

     Only Unit tests are run by developers




                                             41
Continuous Integration

  Different Kind of Tests Exist

     Only Unit tests are run by developers
     Continuous Integration System




                                             41
Continuous Integration

  Provides CI services

     Build Jobs are Tasks

                            MIT License




                                          42
Continuous Integration

  Build Pipeline Plugin




                          43
Continuous Integration

  Build Pipeline Plugin

     Create chains of build jobs.




                                    43
Continuous Integration

  Build Pipeline Plugin

     Create chains of build jobs.




                                    43
Last Note


    No Time No Tests




                       44
Last Note


    No Time No Tests

      Fix an error during Production Time




                                            44
Last Note


    No Time No Tests

      Fix an error during Production Time
    Continuous Delivery




                                            44
Thanks




         45
Questions



                                               Questions ?




How many nights I prayed for this, to let my work begin First we take Manhattan, then we take Berlin - Leonard Cohen
                                                                                                                  46
Questions



                                               Questions ?

                                                                    Alex Soto Bueno

                                                                    asotobu@gmail.com
                                                                    www.lordofthejars.com
                                                                    @alexsotob
How many nights I prayed for this, to let my work begin First we take Manhattan, then we take Berlin - Leonard Cohen
                                                                                                                  46
Credits
http://www.flickr.com/photos/55182004@N04/5518854399/sizes/o/in/photostream/

http://www.flickr.com/photos/wildlifewanderer/6133286089/sizes/o/in/photostream/

http://www.flickr.com/photos/luccawithcheese/3180399980/sizes/o/in/photostream/

http://www.flickr.com/photos/wildlifewanderer/6133286089/sizes/o/in/photostream/

http://www.flickr.com/photos/joachim_s_mueller/6913623388/sizes/o/in/photostream/

http://www.flickr.com/photos/dieselpower83/7078627097/sizes/o/in/pool-62802336@N00/

http://www.flickr.com/photos/soyignatius/2476388983/sizes/o/in/photostream/

http://www.flickr.com/photos/flatbushgardener/440319534/

http://www.flickr.com/photos/justinwkern/3597152639/

http://www.flickr.com/photos/tolgasoran/5154570906/

http://www.flickr.com/photos/pennuja/5363515039/

http://www.flickr.com/photos/350org/5069209808/sizes/o/in/photostream/

http://www.flickr.com/photos/lliurealbir/3484066523/sizes/o/in/photostream/

http://www.flickr.com/photos/windsordi/3467758700/sizes/o/in/photostream/




                                                                                     47
How to Test Enterprise Java Applications
Alex Soto Bueno
Computer Engineer

More Related Content

PDF
JDK9 Features (Summary, 31/Jul/2015) #JJUG
PDF
Make it test-driven with CDI!
ODP
To inject or not to inject: CDI is the question
PDF
JSR-303 Bean Validation API
PPTX
Jdk 7 4-forkjoin
PDF
OSGi and Eclipse RCP
ODP
What's new in Java EE 6
PPTX
Jdk(java) 7 - 6 기타기능
JDK9 Features (Summary, 31/Jul/2015) #JJUG
Make it test-driven with CDI!
To inject or not to inject: CDI is the question
JSR-303 Bean Validation API
Jdk 7 4-forkjoin
OSGi and Eclipse RCP
What's new in Java EE 6
Jdk(java) 7 - 6 기타기능

What's hot (20)

PDF
Python + GDB = Javaデバッガ
PPTX
Java On Speed
PDF
50 new features of Java EE 7 in 50 minutes
ODP
Gradle - time for another build
PDF
Keynote HotSWUp 2012
PPTX
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)
PDF
In the Brain of Hans Dockter: Gradle
PDF
Hierarchy Viewer Internals
PDF
Conf soat tests_unitaires_Mockito_jUnit_170113
PDF
OSGi-enabled Java EE Applications using GlassFish
PDF
5050 dev nation
ODP
Using Grails to power your electric car
PDF
Qt Network Explained (Portuguese)
PDF
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
PDF
Gradle talk, Javarsovia 2010
PDF
Resilence patterns kr
PDF
Vaadin7 modern-web-apps-in-java
KEY
Jggug ws 15th LT 20110224
PPTX
Pure Java RAD and Scaffolding Tools Race
PDF
De Java 8 a Java 17
Python + GDB = Javaデバッガ
Java On Speed
50 new features of Java EE 7 in 50 minutes
Gradle - time for another build
Keynote HotSWUp 2012
Making Exceptions on Exception Handling (WEH 2012 Keynote Speech)
In the Brain of Hans Dockter: Gradle
Hierarchy Viewer Internals
Conf soat tests_unitaires_Mockito_jUnit_170113
OSGi-enabled Java EE Applications using GlassFish
5050 dev nation
Using Grails to power your electric car
Qt Network Explained (Portuguese)
Defcon_Oracle_The_Making_of_the_2nd_sql_injection_worm
Gradle talk, Javarsovia 2010
Resilence patterns kr
Vaadin7 modern-web-apps-in-java
Jggug ws 15th LT 20110224
Pure Java RAD and Scaffolding Tools Race
De Java 8 a Java 17
Ad

Viewers also liked (11)

PDF
Resistance is futile mocks will be assimilated
PDF
03. empaquetado de aplicaciones jee
PDF
Mocks, Stubs and Fakes. ¿What Else?
PPTX
Testing Polyglot Persistence Done Right
PPT
Arquillian - Integration Testing Made Easy
PDF
Desarrollo de pruebas en entornos Java EE
PDF
Jenkins Docker
PDF
Tomcat y Java EE con TomEE {y mucho más}
DOCX
Types of tablets
PPTX
Tablet types and Excipients
PPTX
Pharmaceutical excipients
Resistance is futile mocks will be assimilated
03. empaquetado de aplicaciones jee
Mocks, Stubs and Fakes. ¿What Else?
Testing Polyglot Persistence Done Right
Arquillian - Integration Testing Made Easy
Desarrollo de pruebas en entornos Java EE
Jenkins Docker
Tomcat y Java EE con TomEE {y mucho más}
Types of tablets
Tablet types and Excipients
Pharmaceutical excipients
Ad

Similar to How to Test Enterprise Java Applications (20)

PDF
XML-Free Programming : Java Server and Client Development without &lt;>
PDF
Database Refactoring
PPTX
Selenium Camp 2012
PDF
Surviving The Downturn
PDF
AD114 - Don't be afraid of curly brackets reloaded - even more JavaScript for...
PDF
Agile Testing Practices
PDF
CloudFoundry and MongoDb, a marriage made in heaven
PDF
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
PDF
Grails and the World of Tomorrow
PDF
Agile Seaside
PDF
Seaside — Agile Software Development
PDF
The View - Lotusscript coding best practices
PDF
Bdd and-testing
PDF
Behaviour Driven Development and Thinking About Testing
 
PPTX
Continuous Delivery at Wix
PDF
Scripted - Embracing Eclipse Orion
PDF
State of the art: Server-Side JavaScript - dejeuner fulljs
PPTX
Introductie Visual Studio ALM 2012
PPTX
Introductie Visual Studio ALM 2012
PDF
Paris Web - Javascript as a programming language
XML-Free Programming : Java Server and Client Development without &lt;>
Database Refactoring
Selenium Camp 2012
Surviving The Downturn
AD114 - Don't be afraid of curly brackets reloaded - even more JavaScript for...
Agile Testing Practices
CloudFoundry and MongoDb, a marriage made in heaven
Industrial Strength Groovy - Tools for the Professional Groovy Developer: Pau...
Grails and the World of Tomorrow
Agile Seaside
Seaside — Agile Software Development
The View - Lotusscript coding best practices
Bdd and-testing
Behaviour Driven Development and Thinking About Testing
 
Continuous Delivery at Wix
Scripted - Embracing Eclipse Orion
State of the art: Server-Side JavaScript - dejeuner fulljs
Introductie Visual Studio ALM 2012
Introductie Visual Studio ALM 2012
Paris Web - Javascript as a programming language

More from Alex Soto (20)

PDF
Kubernetes Native Java
PDF
Reactive Programming for Real Use Cases
PDF
Chaos Engineering Kubernetes
PDF
Chaos Engineering Kubernetes
PDF
Microservices testing and automation
PDF
Testing in Production: From DevTestOops to DevTestOps
PDF
Supersonic Subatomic Java
PDF
From DevTestOops to DevTestOps
PDF
Istio service mesh & pragmatic microservices architecture
PDF
Zero Downtime Deployment in Microservices era
PDF
Service Mesh Patterns
PDF
Supersonic, Subatomic Java
PDF
Zero Downtime Deployment in Microservices era
PDF
Long Live and Prosper To Monolith
PDF
Sail in the cloud - An intro to Istio commit
PDF
KubeBoot - Spring Boot deployment on Kubernetes
PDF
Sail in the Cloud - An intro to Istio
PDF
Testing XXIst Century
PDF
Arquillian Constellation
PDF
Testing for Unicorns
Kubernetes Native Java
Reactive Programming for Real Use Cases
Chaos Engineering Kubernetes
Chaos Engineering Kubernetes
Microservices testing and automation
Testing in Production: From DevTestOops to DevTestOps
Supersonic Subatomic Java
From DevTestOops to DevTestOps
Istio service mesh & pragmatic microservices architecture
Zero Downtime Deployment in Microservices era
Service Mesh Patterns
Supersonic, Subatomic Java
Zero Downtime Deployment in Microservices era
Long Live and Prosper To Monolith
Sail in the cloud - An intro to Istio commit
KubeBoot - Spring Boot deployment on Kubernetes
Sail in the Cloud - An intro to Istio
Testing XXIst Century
Arquillian Constellation
Testing for Unicorns

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Big Data Technologies - Introduction.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
sap open course for s4hana steps from ECC to s4
NewMind AI Weekly Chronicles - August'25 Week I
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Big Data Technologies - Introduction.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Network Security Unit 5.pdf for BCA BBA.
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Understanding_Digital_Forensics_Presentation.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
20250228 LYD VKU AI Blended-Learning.pptx
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
sap open course for s4hana steps from ECC to s4

How to Test Enterprise Java Applications

Editor's Notes