Link Search Menu Expand Document

Try in unittest

This section notes how to run YourBase Test Acceleration in your own project that uses the unittest testing framework. For a deeper walkthrough of the library using a sample project, see here.

Table of contents

  1. Prerequisites
  2. Example usage in your project

Prerequisites

Make sure that, on your machine or on your virtual environment:


Example usage in your project

Step 1: Attach yourbase to unittest.

In your tests/__init__.py file, copy-paste the following:

import unittest
import yourbase

yourbase.attach(unittest)

Step 2: Run your project’s tests

For example, to run all the tests for the project, use:

python -m unittest discover

Note: If your tests are going to take a while to run, you can run just a subset of your tests. Running a subset of tests will create a dependency graph just for those tests, so you can see YourBase Test Acceleration in action more quickly.

Step 3: Re-run your tests

Without making a code change, run your tests again using the same command as in step #2. You’ll see that no tests are run. Here, since no code was changed, YourBase Test acceleration ensures that no tests are run.

Step 4: Make a code change in any one of your tests

You can simply add a print statement like below:

print(Checking YourBase Test Acceleration after a code-change...)

Step 5: Run your tests again

Use the same command as in step #2 to run your tests. Here, YourBase Test acceleration ensures that only the one test that you modified is run.