Pycharm - no tests were found?

后端 未结 8 2023
鱼传尺愫
鱼传尺愫 2020-12-18 17:52

I\'ve been getting a

No tests were found

error in Pycharm and I can\'t figure out why I\'m getting it... this is what I have f

相关标签:
8条回答
  • 2020-12-18 18:37

    I know it's more than a year since the question was asked, but I had the same issue and that post was the first result in search.

    As I understood PyCharm (or Intellij Idea Python plugin) needs your test to meet the following criteria if you want it to be launched when you run all the tests in directory.

    1. test functions should start with "test" (underscore is not necessary)
    2. the file, containing the test should also start with "test". "Test" (with capital T doesn't work in my case

    I'm using Intellij IDEA 2016.3.5 with Python plugin

    If you want to run you tests with command line

    python -m unittest
    

    Then you should add __init__.py to test directory. Python still wants your test function names to start with "test", and you test file name to start with "test", but in case of files it doesn't care if the first "t" is capital or not. TestCase and test_case is equally fine.

    0 讨论(0)
  • 2020-12-18 18:41

    One thing that can also cause this problem is if you have not selected the right testing framework in your settings:

    settings > Python Integrated Tools > Testing > Default test runner

    All my tests are in pytest, but it was set to unit test

    0 讨论(0)
提交回复
热议问题