Is it possible to run JUnit tests from multiple packages in Eclipse?

前端 未结 7 1723
Happy的楠姐
Happy的楠姐 2021-02-01 12:43

Is it possible to run JUnit tests for multiple packages at the same time without manually creating test suites.

For example if I have the hierarchy:

code.brancho

相关标签:
7条回答
  • 2021-02-01 13:09

    Maybe not exactly what the original question was, but you can easily run all tests of a whole Project, by simply right-clicking the project -> Run As JUnitTest. Don't worry where the annotated classes reside, this will be scanned.

    This does not work if applied to the test-src-folder or a package with subpackes. Quite a shame actually -.-

    0 讨论(0)
  • An other way:

    Click on the black triangle denoted by red rectangle in the picture below (in your Eclipse, not here :).)

    enter image description here

    Then open run configurations, create a new configuration and then set "Run all tests..." as exemplified in the image below.

    enter image description here

    0 讨论(0)
  • 2021-02-01 13:12

    In Eclipse, on your debug/run configurations you have the following options:

    1. Run a single test
    2. Run all tests in the selected project, package or source folder

    I think the second option is your friend in this case.

    0 讨论(0)
  • 2021-02-01 13:17

    I beleieve that you can add all your test packages to a single directory. If you right click on this directory, then you should find the "run as -> JUnit test" option available. This will run all tests contained in the directory and will catch anything you've added. Any new tests get put in there with the rest of them and whatever package name you have it doesn't matter. Hope that helps

    0 讨论(0)
  • 2021-02-01 13:26

    I'm sure u can tweak this a bit. Make a Collection of the CLASSES_DIR property and loop over it in the findClasses method. (junit4)

    http://burtbeckwith.com/blog/?p=52

    0 讨论(0)
  • 2021-02-01 13:28

    Sure, right-click on the packages you want, and select Run As... JUnit Test

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