简体   繁体   中英

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.

在此处输入图片说明

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.

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.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM