Seeding and Resetting

Learn how to use seed data to create a consistent environment for testing.

To get the most out of testing in Rainforest, you might need to configure your testing environment with seed dataseed data - Information you provide that’s required for testing your application. Examples include usernames, passwords, and roles.. This article helps you prepare your QA environment so that it’s ready for testing in Rainforest.

Definitions

Seeding

Preparing data in your application for testing is called “seeding.” For example, if you have a test that creates a report, you need dummy data to display. Or, if you want testers to log in, you need test accounts with login credentials.

Isolation

Sometimes, tests must execute independently without adversely affecting the outcome of other tests. For some applications, using multiple user accounts is sufficient. For others, if the scope of a test’s actions is larger than a single user account, then the extent of their isolation must be greater as well. For example, your app might include organizations or teams, and each tester needs their own.

Resetting

Each time a test executes, our testers work with test accounts, and the data is modified according to the test steps. To rerun the test, the data must return to its starting state so the test doesn’t fail. Your application should do this by restoring the database image or running a migration.

Sample Techniques for Preparing Your QA Environment

Factories

In object-oriented programming (OOP), a factory is code that creates an object. Use factories in your seeding scripts to provide realistic data for testing. Factory Bot and Factory Boy are two popular options for Ruby and Python.

>>> user = UserFactory.build(first_name='Joe')
>>> user.first_name
"Joe"

Faker

Many programming languages offer faker packages. Their purpose is to create believable data for testing. For example, you might call faker.first_name to return a person’s first name from a list.

Here are a few of the many faker packages available:

fake = Faker()

fake.name()
# 'Mars Williams'

Production Data

Copying data from Production is often the fastest way to create data for testers. However, using live data can introduce privacy concerns around personally identifiable information (PII), such as address, phone number, and Social Security number.

If you decide to use production data for testing, make sure to anonymize it first. To learn more, check out The Fundamentals of Data Anonymization and Protection from DATAVERSITY.

Webhooks

Rainforest uses webhooks to notify you when a test has started or stopped so you can perform any required setup or teardown steps. For more information, see Using Webhooks.

Method POST
URL  https://my-staging-app.com/webhooks/rainforestqa
Body  {
     “callback_type”: “before_run”,
     “options”: {
       “run_id”: “12345”
     },
     “digest”: “ADIGESTSTRING”
   }

If you have any questions, reach out to us at [email protected] or via the chat bubble below.


Did this page help you?