Skip to content

Instantly share code, notes, and snippets.

@eliasnogueira
Last active February 2, 2023 08:56
Show Gist options
  • Save eliasnogueira/6af365821889025a3be1684b62d0517f to your computer and use it in GitHub Desktop.
Save eliasnogueira/6af365821889025a3be1684b62d0517f to your computer and use it in GitHub Desktop.

Title

Managing Testing Data

Description

Have you ever tried to troubleshoot an issue taking a looking at the log files? I bet you did! And it turns out the issue is related to data usage because, you know, users will use real data! Developers won't! A good thing about your recent troubleshooting is that you can understand the data. It's not a bunch of numbers or UUIDs in the name field. How about your development environment? Probably you use either hard-coded data or random strings. We must fix that!

This presentation will show you how to manage testing data in two different ways.

The first way is the creation of a Test Data Factory approach, where we will use the Factory Pattern to easily create any objects we want with understandable and reliable data. This approach will make you in control of your own data, so you can find any bug in the early stages of the SDLC and the DataFaker library will help us to generate good random data in every execution.

In a second way, we will learn and apply the Data-Driven Testing approach, where the same requirement can be applied to different sets of data, generating different results. This approach can reduce the amount of code and the execution time. With the support of JUnit 5 you will learn how to do it in 5 different ways: value source, internal method source, external method source, argument provider, and CVS source.

During this presentation you will learn how to write Data-Driven tests using JUnit 5 in a Spring Boot application in the integration layer, using the Test Data Factory approach to easily create all the necessary and reliable data.

Technologies in use

  • Java 17
  • JUnit 5 to create the integration tests, along with AssertJ as the assertion library
  • DataFaker as a data generation library
  • SpringBoot to show the application under test, which is a microservice with a few business rules

Takeaways

  • Learn how to better manage testing data and find bugs faster
  • Learn to use Data-Driven Testing in different ways using JUnit 5
  • Learn how to apply the Factory pattern to better create different types of data

Elevator pitch

The usage of self-generated and reliable data is mandatory to prevent any issue, and the creation of it requires the correct usage of designs and techniques to achieve bug-free software. Discover in this presentation how to apply the Factory Pattern along with the Data-Driven testing approach to reduce time, effort, and bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment