Ray
Ray

Reputation: 8623

How to force Pycharm to run all unit tests?

I have a single unit test file, and I can run tests within Pycharm. Fine. However, it seems that Pycharm skips tests based on some criteria regarding code change. Something like, if the code in a test method hasn't changed, and/or if the code that a particular test method is testing hasn't changed, it won't run the test. This has caused a lot of pain, and has let a bug fall through that wasn't caught until much later on. So my question is, how to stop Pycharm from automatically skipping tests and force it to run all tests?

Why is skipping tests the default behaviour anyway? This seems absolutely outrageous to me, but please correct me if I'm wrong.

EDIT Oops my bad. I ran the tests by pressing the keyboard shortcut control-shift-R on my Mac OS, which normally runs a Python script, but it doesn't actually run the whole test file, and only runs a single test (where the caret is) instead. This (keyboard shortcut having different behaviours) is a little bit misleading in my opinion, but regardless, my description of the problem is wrong and I was wrong. Sorry!

Upvotes: 1

Views: 1653

Answers (1)

Bendeberia
Bendeberia

Reputation: 116

Make sure all your test methods staring with a test_.

Usually I have 2 Tests configurations: All and Current.

enter image description here enter image description here

tests folder is located in the root of PyCharm project

I use python path to specify certain test to run. You can easily copy the reference to certain test enter image description here

Upvotes: 3

Related Questions