Integration testing is difficult as you need additional systems, like a database, with a predefined set of data to have repeatable tests.
With the availability of the Testcontainers framework, developers can test the real application by deploying it in a container using the runtime that will be used in production and dependencies available in other containers.
In this session, we explore a few scenarios of how you can use the Testcontainers framework to test your Jakarta EE application, including a remote debug session of your code.
5. Rudy De Busscher
Rudy De Busscher
Jakarta EE Expert
Owner of Atbash
@rdebusscher@mastodon.online
https://www.atbash.be
6. Unit vs Integration Testing
Unit Testing: Individual methods
Fast, Easy
Business relation
Integration testing : Multiple components, systems,
Realistic
Slow, Brittle,
Rudy De Busscher
9. Integration testing with Jakarta EE
Weld JUnit
(Arquillian)
(MicroShed Testing)
Atbash integration testing
Testcontainers
WireMock
Database containers and DBUnit
Rudy De Busscher
10. 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
13. 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
15. 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
16. 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
17. 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
18. 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
20. 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
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
23. (Integration) Testing with Jakarta EE
Preferred stack
Unit testing
JUnit 5
Logic testing
Weld JUnit
Integration testing
Atbash Integration Testing
Rudy De 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)