Skip to content

Latest commit

 

History

History
1021 lines (733 loc) · 38.3 KB

slides.md

File metadata and controls

1021 lines (733 loc) · 38.3 KB
theme background class highlighter lineNumbers info drawings transition css
default
/assets/images/cat.jpeg
text-center
shiki
true
## audrey's slidev template github: https://github.com/audreycj
persist
slide-left
unocss

Java Unit Testing Frameworks, Libraries, and Tools

by Audrey Nanual


layout: center

Testing Framework

  • a collection of reusable code that provides functionality to support unit testing, such as assertion methods, mock objects, or test data generators
  • e.g. JUnit 5, Mockito, SpringFramework Testing, Spring Boot Testing, Selenide

Testing Library

  • a set of conventions and rules that define how tests are written, organized, and executed
  • e.g. AssertJ, Data Faker, Easy Random, Easy Random JUnit Extension, ModelAssert,

Testing Tool

  • a software application that helps developers automate and manage the process of testing software
  • e.g. JUnit Pioneer, Database Rider, TestContainers, Instancio, JetBrains Aqua

layout: center

Frameworks, libraries, and tools for today

  1. JUnit 5
  2. JUnit Pioneer
  3. AssertJ
  4. Data Faker
  5. Mockito
  6. Easy Random
  7. Easy Random JUnit Extension
  8. Database Rider
  9. ModelAssert
  10. SpringFramework Testing
  11. Spring Boot Testing
  12. TestContainers
  13. Instancio
  14. Selenide
  15. JetBrains Aqua

layout: center

JUnit 5

“Powerful and flexible Java testing framework”

Latest version of the popular Java testing framework, JUnit.

Provides a range of new features and enhancements to help developers write more efficient, effective, and maintainable tests.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Modular and extensible architecture
  2. New programming model (i.e., @Nested, @ParameterizedTest, @DynamicTest)
  3. Improved exception handling
  4. Test templates
  5. Parallel test execution
  6. Improved reporting

layout: center

JUnit Pioneer

“Making JUnit 5 testing simpler and more accessible”

An open-source testing tool that extends JUnit 5 to provide additional testing features.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Enhanced test reporting
  2. Improved parameterized tests
  3. Test fixtures with constructor injection
  4. Enhanced test data management
  5. Test isolation with separate class loaders

layout: center

AssertJ

“Readable and comprehensive assertions for Java”

A fluent assertions library for Java that provides a more

readable and comprehensive way of writing assertions in unit tests.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Fluent interface —— ❌ assertTrue(x > 0) | ✅ assertThat(x).isGreaterThan(0)
  2. Type-specific assertions (i.e., collections, strings, dates, and exceptions)
  3. Chained assertions
assertThat(str)
      .startsWith("JUnit")
      .endsWith("framework")
      .contains("unit testing");
  1. Soft assertions

  2. Custom error messages


layout: center

Data Faker

“Realistic data generation made easy”

A Java library that generates realistic and randomized test data for a wide range of data types,

allowing developers to quickly and easily populate their unit tests with diverse and comprehensive test data.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Wide variety of data types
  2. Localization support
  3. Customization
  4. Easy integration
  5. High-quality data

layout: center

Mockito

“Mocking framework for unit testing in Java”

A Java mocking framework that allows developers to create mock objects, stub method behavior,

and verify the interactions between objects in unit tests.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Simple and intuitive syntax
  2. Stubbing
  3. Verification
  4. Spying
  5. Argument matching (i.e., exact matches, wildcard matches, and argument capture)
  6. Annotation support (i.e., @Mock, @InjectMocks)
  7. Ability to mock final classes and methods

layout: center

Easy Random

“Flexible test data generation”

A Java library that simplifies the process of generating randomized test data,

making it easier to write comprehensive and efficient tests.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Fluent interface
  2. Customizable
  3. Supports complex object generation
  4. Supports a wide range of data types
  5. Automatic configuration
  6. Easy integration
  7. Provide randomness control

layout: center

Easy Random JUnit Extension

“Seamless test data generation”

An extension to the Easy Random library that integrates with JUnit 5 to generate random test data.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. @EasyRandom
  2. @WithEasyRandom
  3. @EasyRandomResource
  4. @Randomizer
  5. @Random
  6. @RandomBean

layout: center

Database Rider

“Database testing made easy”

A testing tool that provides support for testing database-related functionality in Java applications,

allowing developers to create and manage test data and execute tests in an automated and repeatable manner.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Supports multiple database types
  2. Supports data-driven testing
  3. Provides fluent API for database operations
  4. Integration with JUnit and TestNG
  5. Supports transaction management
  6. Supports assertions on database state

layout: center

ModelAssert

“Model-based testing”

A Java testing library that allows developers to define models for objects and collections,

and then use these models to assert that the state and behavior of objects and collections conform to expected models.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Model-based testing with graphs
  2. Domain-specific assertions
  3. Value object testing
  4. Flexible model definition
  5. Data-driven testing
  6. Lightweight and easy to use

layout: center

SpringFramework Testing

“Simplified testing of Spring applications”

Provides support for testing Spring-based applications, including unit testing, integration testing,

and end-to-end testing, using a variety of testing frameworks and tools.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Integration testing
  2. Mock objects
  3. Dependency injection
  4. Annotations (i.e., @RunWith, @ContextConfiguration, and @Autowired)
  5. Flexible configuration
  6. Test templates

layout: center

Spring Boot Testing

“Testing made easy for Spring Boot”

A module of the Spring Boot framework that provides support for testing Spring Boot applications,

including unit testing, integration testing, and end-to-end testing.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Auto-configuration
  2. Mocking and testing
  3. Integration testing
  4. Test annotations (i.e., @SpringBootTest, @MockBean)
  5. Test utilities (i.e., TestRestTemplate class)
  6. Test slices (i.e., @WebMvcTest, @DataJpaTest )

layout: center

TestContainers

“Containerized testing made simple”

A Java testing library that allows developers to easily create and manage disposable test containers,

such as databases, for their unit and integration tests.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Containerization
  2. Wide range of supported containers (i.e., MySQL, PostgreSQL, Oracle, RabbitMQ, Apache Kafka)
  3. Automated container management
  4. Dependency management
  5. Simple API
  6. Compatibility with existing testing frameworks

layout: center

Instancio

“Dynamic test data generation library”

A library for instantiating and populating objects with random data, making your tests more dynamic

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Reduces manual data setup in unit tests
  2. Non-intrusive and concise API
  3. Allows customization of generated objects
  4. Requires no changes to production code
  5. Can be used out-of-the-box with zero config

layout: center

Selenide

"Java UI testing made easy."

A concise and easy-to-use Java-based UI automation testing framework that leverages the Selenium WebDriver library.

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Concise and readable syntax
  2. Automatic waits
  3. Screenshots on failures
  4. Support for multiple browsers
  5. Page Object Model (POM) support
  6. Fluent API
  7. Automatic handling of iframes
  8. Advanced assertions

layout: center

JetBrains Aqua

"A powerful new IDE for test automation"

<style> blockquote { code { @apply text-teal-500 dark:text-teal-400; } } </style>
  1. Intelligent coding assistance
  2. Unit test frameworks
  3. UI automation (i.e., New Project wizard, Code Insight, Page Object Templates)
  4. Web inspector
  5. API testing and environment setup (i.e., HTTP, Docker)
  6. Database
  7. Test management systems (TMS)

layout: center

Summary

  1. JUnit 5 — A popular unit testing framework for Java.
  2. JUnit Pioneer — An open-source testing tool that extends JUnit 5 to provide additional testing features.
  3. AssertJ — A library that provides fluent assertions for Java.
  4. Data Faker — A library that generates random data for testing purposes.
  5. Mockito — A mocking framework for Java that allows you to create mock objects for testing.

layout: center

Summary (cont.)

  1. Easy Random — A library that generates random data for testing purposes.
  2. Easy Random JUnit Extension — An extension to the Easy Random library that integrates with JUnit 5 to generate random test data.
  3. Database Rider — A testing tool that provides a convenient way to manage and populate database instances for testing purposes.
  4. ModelAssert — A library that provides fluent assertions for testing object models.
  5. SpringFramework Testing — A testing framework that provides support for testing Spring-based applications.

layout: center

Summary (cont.)

  1. Spring Boot Testing — A testing framework that provides support for testing Spring Boot applications.
  2. TestContainers — A testing tool that allows you to easily run applications in containers for testing purposes.
  3. Instancio — A testing tool that generates test data by analyzing the source code of the classes being tested.
  4. Selenide — A testing framework that provides a concise API for writing UI tests using Selenium WebDriver.
  5. JetBrains Aqua — A testing tool (IDE) for test automation

layout: center

More info on the presented testing tools


layout: end