How To Be a Java Automated Testing Superstar

VMware Tanzu
VMware TanzuVMware Tanzu
How to Be a Java Automated Testing
Superstar!
Billy Korando
Oracle - Java Developer Advocate ☕🥑
@BillyKorando
• Ask questions
• Reach out:
Twitter: @BillyKorando
Email: billy.korando@oracle.com
• Key link 👉 https://github.com/wkorando/java-testing-superstar
Important Notes
Copyright © 2021, Oracle and/or its affiliates
2
Copyright © 2021, Oracle and/or its affiliates
3
https://billykorando.com/
My code is perfect!
Why should I waste time writing tests?
Why Write Automated Tests?
Copyright © 2021, Oracle and/or its affiliates
4
• Substantial time and effort to write tests
• Substantial time and effort to maintain tests
🏠
Why Write Automated Tests?
Copyright © 2021, Oracle and/or its affiliates
5
CI/CD Process =>
🧱🧱🧱🧱🧱🧱
🧱🧱🧱🧱🧱🧱🧱🧱
🧱🧱🧱🧱🧱🧱🧱🧱
Automated Tests =>
Deployment Process
Copyright © 2021, Oracle and/or its affiliates
6
🌎
Deploy to Prod
👩💻🧑💻
👨💻
Developers
Commit Code
🔨
Build & Test
Code
✅✅
✅
🛴
Manual Process
Takes hours or days
The code
your code
runs on
The Dependency Iceberg
Copyright © 2021, Oracle and/or its affiliates
7
Your Code
{
• Security patches
• Performance
enhancements
• Feature
enhancements
Manual Test Costs
Copyright © 2021, Oracle and/or its affiliates
8
The high effort of regression testing code
disincentivizes keeping dependencies up-to-date
Deployment Process
Copyright © 2021, Oracle and/or its affiliates
9
🌎
Deploy to Prod
👩💻🧑💻
👨💻
Developers
Commit Code
🔨
Build & Test
Code
✅✅
✅
🏍
Automated Process
Measured in minutes
Auditable 🕵
• Can review test code, reports, and logging
Repeatable ↻
• Can re-run test suite to see if problems persists
• Can run test suite against other code base/version to see if problem exists
Additional Benefits
Copyright © 2021, Oracle and/or its affiliates
10
Whatever gives you confidence to
deploy to PROD without manual
intervention
How Many Automated Test Should I Write?
Copyright © 2021, Oracle and/or its affiliates
11
Manual testing still needed.
But it’s exploratory testing.
Manual Testing
Copyright © 2021, Oracle and/or its affiliates
12
How to be an Automated Testing
Superstar?
Copyright © 2021, Oracle and/or its affiliates
13
✅ Treat Test Code like “Production” Code
✅ Write Human Readable Tests
How to be an Automated Testing Superstar?
Copyright © 2021, Oracle and/or its affiliates
14
• Parallel test execution
• Repeated tests
• Extensions
• Selective disabling
• Default test methods
• And more!
JUnit 5 Not Covered
[Date]
Copyright © 2021, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted
15
AssertJ – Fluent Assertions
Copyright © 2021, Oracle and/or its affiliates
16
AssertJ – Fluent Assertions
Copyright © 2021, Oracle and/or its affiliates
17
✅ Write Reliable Tests
How to be an Automated Testing Superstar?
Copyright © 2021, Oracle and/or its affiliates
18
Test Containers
Copyright © 2021, Oracle and/or its affiliates
19
Test Containers
Copyright © 2021, Oracle and/or its affiliates
20
• Test against local containerized instances of remote services
• Don’t have to worry about:
• Service being down
• Test data going missing
• Maintain local instance
JFRUnit
Copyright © 2021, Oracle and/or its affiliates
21
JFRUnit
Copyright © 2021, Oracle and/or its affiliates
22
• Capture JDK Flight Recorder (JFR) Events to track system performance behavior
• Check JVM behavior consistent across systems and environments
Contract Driven Development (Spring Cloud Contract)
Copyright © 2021, Oracle and/or its affiliates
23
Contract Driven Development (Spring Cloud Contract)
Copyright © 2021, Oracle and/or its affiliates
24
• Contracts validate service fulfill defined behavior
• Contracts can be used to setup up mock of service
Junit 5, Mockito, AssertJ, and Test Containers:
https://github.com/wkorando/welcome-to-junit5-v2
Spring Cloud Contract Example:
https://github.com/wkorando/collaborative-contract-driven-development-2-0
JFRUnit:
https://github.com/wkorando/testing-tuesday/tree/main/xxx-jfr-unit
Code Examples
Copyright © 2021, Oracle and/or its affiliates
25
Thank you
26 Copyright © 2021, Oracle and/or its affiliates
How To Be a Java Automated Testing Superstar
1 of 27

More Related Content

Similar to How To Be a Java Automated Testing Superstar(20)

SCWCD 5 preparation guideSCWCD 5 preparation guide
SCWCD 5 preparation guide
Ganesh P858 views
Coding Together - A Dev WorkflowCoding Together - A Dev Workflow
Coding Together - A Dev Workflow
Peter Chester1.2K views
SCDJWS 5 preparation guideSCDJWS 5 preparation guide
SCDJWS 5 preparation guide
Ganesh P737 views
DevOps in an Embedded WorldDevOps in an Embedded World
DevOps in an Embedded World
Sajeewa Dayaratne983 views
Quality LoopbackQuality Loopback
Quality Loopback
Omar Bashir138 views
Tools for Software TestingTools for Software Testing
Tools for Software Testing
Mohammed Moishin251 views

Recently uploaded(20)

Oxygen JSON EditorOxygen JSON Editor
Oxygen JSON Editor
Octavian Nadolu19 views
Java-ML-lego-j-fallJava-ML-lego-j-fall
Java-ML-lego-j-fall
Jago de Vreede45 views
Green Cloud - Measure cloud emissionsGreen Cloud - Measure cloud emissions
Green Cloud - Measure cloud emissions
Green Software Development14 views
Like SpecFlowLike SpecFlow
Like SpecFlow
Dmitry Dorogoy9 views
The Case Against Frameworks - JFall 2023The Case Against Frameworks - JFall 2023
The Case Against Frameworks - JFall 2023
Jan-Hendrik Kuperus12 views
New Groundbreaking AI App.pdfNew Groundbreaking AI App.pdf
New Groundbreaking AI App.pdf
Anwar78Talukder5 views

How To Be a Java Automated Testing Superstar

  • 1. How to Be a Java Automated Testing Superstar! Billy Korando Oracle - Java Developer Advocate ☕🥑 @BillyKorando
  • 2. • Ask questions • Reach out: Twitter: @BillyKorando Email: billy.korando@oracle.com • Key link 👉 https://github.com/wkorando/java-testing-superstar Important Notes Copyright © 2021, Oracle and/or its affiliates 2
  • 3. Copyright © 2021, Oracle and/or its affiliates 3 https://billykorando.com/
  • 4. My code is perfect! Why should I waste time writing tests? Why Write Automated Tests? Copyright © 2021, Oracle and/or its affiliates 4 • Substantial time and effort to write tests • Substantial time and effort to maintain tests
  • 5. 🏠 Why Write Automated Tests? Copyright © 2021, Oracle and/or its affiliates 5 CI/CD Process => 🧱🧱🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱 🧱🧱🧱🧱🧱🧱🧱🧱 Automated Tests =>
  • 6. Deployment Process Copyright © 2021, Oracle and/or its affiliates 6 🌎 Deploy to Prod 👩💻🧑💻 👨💻 Developers Commit Code 🔨 Build & Test Code ✅✅ ✅ 🛴 Manual Process Takes hours or days
  • 7. The code your code runs on The Dependency Iceberg Copyright © 2021, Oracle and/or its affiliates 7 Your Code { • Security patches • Performance enhancements • Feature enhancements
  • 8. Manual Test Costs Copyright © 2021, Oracle and/or its affiliates 8 The high effort of regression testing code disincentivizes keeping dependencies up-to-date
  • 9. Deployment Process Copyright © 2021, Oracle and/or its affiliates 9 🌎 Deploy to Prod 👩💻🧑💻 👨💻 Developers Commit Code 🔨 Build & Test Code ✅✅ ✅ 🏍 Automated Process Measured in minutes
  • 10. Auditable 🕵 • Can review test code, reports, and logging Repeatable ↻ • Can re-run test suite to see if problems persists • Can run test suite against other code base/version to see if problem exists Additional Benefits Copyright © 2021, Oracle and/or its affiliates 10
  • 11. Whatever gives you confidence to deploy to PROD without manual intervention How Many Automated Test Should I Write? Copyright © 2021, Oracle and/or its affiliates 11
  • 12. Manual testing still needed. But it’s exploratory testing. Manual Testing Copyright © 2021, Oracle and/or its affiliates 12
  • 13. How to be an Automated Testing Superstar? Copyright © 2021, Oracle and/or its affiliates 13
  • 14. ✅ Treat Test Code like “Production” Code ✅ Write Human Readable Tests How to be an Automated Testing Superstar? Copyright © 2021, Oracle and/or its affiliates 14
  • 15. • Parallel test execution • Repeated tests • Extensions • Selective disabling • Default test methods • And more! JUnit 5 Not Covered [Date] Copyright © 2021, Oracle and/or its affiliates | Confidential: Internal/Restricted/Highly Restricted 15
  • 16. AssertJ – Fluent Assertions Copyright © 2021, Oracle and/or its affiliates 16
  • 17. AssertJ – Fluent Assertions Copyright © 2021, Oracle and/or its affiliates 17
  • 18. ✅ Write Reliable Tests How to be an Automated Testing Superstar? Copyright © 2021, Oracle and/or its affiliates 18
  • 19. Test Containers Copyright © 2021, Oracle and/or its affiliates 19
  • 20. Test Containers Copyright © 2021, Oracle and/or its affiliates 20 • Test against local containerized instances of remote services • Don’t have to worry about: • Service being down • Test data going missing • Maintain local instance
  • 21. JFRUnit Copyright © 2021, Oracle and/or its affiliates 21
  • 22. JFRUnit Copyright © 2021, Oracle and/or its affiliates 22 • Capture JDK Flight Recorder (JFR) Events to track system performance behavior • Check JVM behavior consistent across systems and environments
  • 23. Contract Driven Development (Spring Cloud Contract) Copyright © 2021, Oracle and/or its affiliates 23
  • 24. Contract Driven Development (Spring Cloud Contract) Copyright © 2021, Oracle and/or its affiliates 24 • Contracts validate service fulfill defined behavior • Contracts can be used to setup up mock of service
  • 25. Junit 5, Mockito, AssertJ, and Test Containers: https://github.com/wkorando/welcome-to-junit5-v2 Spring Cloud Contract Example: https://github.com/wkorando/collaborative-contract-driven-development-2-0 JFRUnit: https://github.com/wkorando/testing-tuesday/tree/main/xxx-jfr-unit Code Examples Copyright © 2021, Oracle and/or its affiliates 25
  • 26. Thank you 26 Copyright © 2021, Oracle and/or its affiliates