Jakarta EE
Integration Testing
Rudy De Busscher
Rudy De Busscher
Rudy De Busscher
Photo by Brett Jordan on Unsplash
Rudy De Busscher
Rudy De Busscher
Rudy De Busscher
Jakarta EE Expert
• Owner of Atbash
@rdebusscher@mastodon.online
https://www.atbash.be
Unit vs Integration Testing
• Unit Testing: Individual methods
• Fast, Easy
• Business relation
• Integration testing : Multiple components, systems, …
• Realistic
• Slow, Brittle, …
Rudy De Busscher
Testing
• 10%
• 20%
• 70%
Rudy De Busscher
Manual
Rudy De Busscher
Testing 1.0
Integration testing with Jakarta EE
• Weld JUnit
• (Arquillian)
• (MicroShed Testing)
• Atbash integration testing
• Testcontainers
• WireMock
• Database containers and DBUnit
Rudy De Busscher
Weld JUnit
• Test business logic
• First release around 2016
• Spin up CDI container
• Limited set of CDI beans
• Can be used with Mocks
Rudy De Busscher
Rudy De Busscher
Demo
Arquillian
• Executing real tests. (From website)
• First release 2011 - 2012
Rudy De Busscher
Arquillian
• Managing the lifecycle of the container (or containers)
• Bundling the test case, dependent classes and resources into a
ShrinkWrap archive (or archives)
• Deploying the archive (or archives) to the container (or containers)
• Enriching the test case by providing dependency injection and
other declarative services
• Executing the tests inside (or against) the container
• Capturing the results and returning them to the test runner for
reporting
Rudy De Busscher
Rudy De Busscher
Demo
Arquillian Active?
• Since 2018 very low to no activity
• Version 1.7 in alpha since April 2020
• Good documentation/examples for Jakarta EE 9 by Hantsy Bai
• https://github.com/hantsy/jakartaee9-starter-boilerplate
Rudy De Busscher
Issues
• Not real WAR file
• Do we test actual functionality (see also 12 factor app)
• Connectors for runtimes need to be maintained
• Complex
• Assemble required classes
• Error information easily lost
Rudy De Busscher
Testcontainers
• First release 2016
• Components run in Docker Container.
• Easy Integration of components.
• No limitations on external dependencies.
• Complete control over components in test.
Rudy De Busscher
12-factor app friendly
Features
• Repeatable tests using real systems
• Database, monitoring, …
• Selenium to verify frontend of your application
• Simulating cluster on single computer
• Simulating network issues
• Manual testing / debugging realistic scenarios
Rudy De Busscher
Rudy De Busscher
Simplified setup
• MicroShed testing (first release 2019)
• Jakarta EE 8 - Abandoned (no activity for 2 years)
• Atbash Integration Testing
• Jakarta EE 8+ support
• Flexible / simple setup
• Testing multiple applications (microservices)
• WireMock for mocking dependencies
• Support for Databases
Rudy De Busscher
Atbash Integration Testing
• War app itself under test
• Support for
• Payara Micro
• OpenLiberty
• WildFly
• Glassfish
• Dependencies through Testcontainers
• Databases, custom images
• WireMock
• Mocking remote services.
Rudy De Busscher
Rudy De Busscher
Demo
(Integration) Testing with Jakarta EE
• Preferred stack
• Unit testing
• JUnit 5
• Logic testing
• Weld JUnit
• Integration testing
• Atbash Integration Testing
Rudy De Busscher
Q & A
Rudy De Busscher
Thank you
•Atbash
• Blog
• https://www.atbash.be
• Github
• https://github.com/atbashEE
Rudy De Busscher
THANK YOU!
COPYRIGHT (C) 2023, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)

jakarta-integration-testing.pdf

  • 1.
  • 2.
  • 3.
    Rudy De Busscher Photoby Brett Jordan on Unsplash
  • 4.
  • 5.
    Rudy De Busscher RudyDe Busscher Jakarta EE Expert • Owner of Atbash @rdebusscher@mastodon.online https://www.atbash.be
  • 6.
    Unit vs IntegrationTesting • Unit Testing: Individual methods • Fast, Easy • Business relation • Integration testing : Multiple components, systems, … • Realistic • Slow, Brittle, … Rudy De Busscher
  • 7.
    Testing • 10% • 20% •70% Rudy De Busscher Manual
  • 8.
  • 9.
    Integration testing withJakarta EE • Weld JUnit • (Arquillian) • (MicroShed Testing) • Atbash integration testing • Testcontainers • WireMock • Database containers and DBUnit Rudy De Busscher
  • 10.
    Weld JUnit • Testbusiness logic • First release around 2016 • Spin up CDI container • Limited set of CDI beans • Can be used with Mocks Rudy De Busscher
  • 11.
  • 12.
    Arquillian • Executing realtests. (From website) • First release 2011 - 2012 Rudy De Busscher
  • 13.
    Arquillian • Managing thelifecycle of the container (or containers) • Bundling the test case, dependent classes and resources into a ShrinkWrap archive (or archives) • Deploying the archive (or archives) to the container (or containers) • Enriching the test case by providing dependency injection and other declarative services • Executing the tests inside (or against) the container • Capturing the results and returning them to the test runner for reporting Rudy De Busscher
  • 14.
  • 15.
    Arquillian Active? • Since2018 very low to no activity • Version 1.7 in alpha since April 2020 • Good documentation/examples for Jakarta EE 9 by Hantsy Bai • https://github.com/hantsy/jakartaee9-starter-boilerplate Rudy De Busscher
  • 16.
    Issues • Not realWAR file • Do we test actual functionality (see also 12 factor app) • Connectors for runtimes need to be maintained • Complex • Assemble required classes • Error information easily lost Rudy De Busscher
  • 17.
    Testcontainers • First release2016 • Components run in Docker Container. • Easy Integration of components. • No limitations on external dependencies. • Complete control over components in test. Rudy De Busscher 12-factor app friendly
  • 18.
    Features • Repeatable testsusing real systems • Database, monitoring, … • Selenium to verify frontend of your application • Simulating cluster on single computer • Simulating network issues • Manual testing / debugging realistic scenarios Rudy De Busscher
  • 19.
  • 20.
    Simplified setup • MicroShedtesting (first release 2019) • Jakarta EE 8 - Abandoned (no activity for 2 years) • Atbash Integration Testing • Jakarta EE 8+ support • Flexible / simple setup • Testing multiple applications (microservices) • WireMock for mocking dependencies • Support for Databases Rudy De Busscher
  • 21.
    Atbash Integration Testing •War app itself under test • Support for • Payara Micro • OpenLiberty • WildFly • Glassfish • Dependencies through Testcontainers • Databases, custom images • WireMock • Mocking remote services. Rudy De Busscher
  • 22.
  • 23.
    (Integration) Testing withJakarta EE • Preferred stack • Unit testing • JUnit 5 • Logic testing • Weld JUnit • Integration testing • Atbash Integration Testing Rudy De Busscher
  • 24.
    Q & A RudyDe Busscher
  • 25.
    Thank you •Atbash • Blog •https://www.atbash.be • Github • https://github.com/atbashEE Rudy De Busscher
  • 26.
    THANK YOU! COPYRIGHT (C)2023, ECLIPSE FOUNDATION. | THIS WORK IS LICENSED UNDER A CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE (CC BY 4.0)