简体   繁体   中英

How can I run all junit tests in a package and below (recursively) by right clicking the package on eclipse and selecting “Run as JUnit test”

I found similar questions but no satisfactory answers. In addition, most answers were rather old as well, so I wonder if the combination eclipse / Junit got better in the meantime.

Instead of packing projects into test suites, I would like to spread tests cases all over the place in the package structure (I'm programming in Java). Then right clicking on whatever package (on the package explorer) should bring the option Run As -> JUnit Test and run all the unit tests in that package and below (recursively). In this way, I wouldn't have to care about maintaining the test structure, it would be in the packages themselves.

I've seen that this works only with end packages (with no children), but not recursively. Do you have any ideas? I'm using eclipse Kepler (4.3.0), JUnit 4 and Java 1.6.

Why cant you create a run config in eclipse to run all the JUnit tests ? Refer the screen shot. Select the radio button which says

Run All tests in the selected project, package or source 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