Christof Vermeersch
Christof Vermeersch

Reputation: 495

Run multiple unittest test files at once

In my project I created a unittest test file for each Python file. For example, I have file component.py and its accompanying test_component.py. Similarly for path.py and test_path.py, etc.

However, since these files depend on each other it is possible that a change in one file affects another, thus if I change something I need to rerun all my testfiles. For now, I have to do this manually. Is it possible to run all these test files at once with only one handling? Maybe call them from an extra file? I want however still use the testsuite as before (see the image below).

I am using Python 2.7 and JetBrains' PyCharm.

enter image description here

Upvotes: 0

Views: 2025

Answers (2)

user2235698
user2235698

Reputation: 7619

It's possible to run all tests located in some folder.

Go to Run - Edit Configurations, select or create run configuration for tests and specify path to folder.

enter image description here

Upvotes: 1

SkylerHill-Sky
SkylerHill-Sky

Reputation: 2206

I would recommend using Pytest.

Another alternative is to have a separate file that calls tests or instantiates classes from each test file. Based on the returns it calls the next test.

You also might have a need store information in a .txt file. You could write and read to a file that holds your test variables, conditions, etc.

Upvotes: 1

Related Questions