如何让 IntelliJIDEA 运行包含子包的包中的所有测试

如果我单击一个包并执行 control-shift-F10,它只会查找并运行该包中的 JUnit 测试——但我真的希望它递归到子包中并运行它们。

更新: 看起来好像有什么别的问题。当我在一个包含测试的包上运行它时,它仍然抱怨没有测试(但是如果我打开一个 JUnit 测试,我可以很好地运行它)。

51042 次浏览

The default key combination to run all tests is Ctrl+Shift+F10

  1. Run->Edit Configurations...
  2. Create a new junit test configuration
  3. Name it "All tests"
  4. Include entire package
  5. Apply/Run.

enter image description here

From @andersoyvind's comment.

I've solved this thanks to csauve response. This could be an answer to his, but I didn't know how to include an image there.

Run/Debug Configurations dialog box can be access via Run > Edit Configurations. Use these options to create one that runs all your tests:

Run/Debug configuration for all tests

For Python users:

  1. Include __init__.py in each subfolder
  2. Create a dummy_test.py in the root of your tests directory, eg.:
class DummyTest(TestCase):
pass

(credit to this answer)