如何一次运行我所有的内部类junit测试

Joe*_*Joe 4 java eclipse junit

我按照描述的方法使用每个方法使用一个内部类来组织我的junit测试:

在这里,在一个haacked文章(关于nunit测试),和
这里,在这个SO问题

public class TestMyThing {

    public static class TestMyThingMethodOne {

        @Test
        public void testMethodOneDoesACertainBehaviour() {
            // terse, clear testing code goes here
        }

        @Test
        public void testMethodOneHasSomeOtherDesiredBehaviour() {
            // more inspiring testing code here
        }
    }

    public static class TestMyThingMethodTwo {
        ... etc
    }
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试为此运行junit测试时,Eclipse会询问我要运行哪个内部类测试,而我只能选择一个.有没有一种方法可以指定我希望每个内部类中的每个测试都能运行TestMyThing类?

Joe*_*Joe 7

我在这篇文章中在Eclipse论坛上提出了我的问题,结果证明Eclipse可以运行所有内部类.我引用了我已经尝试过的回复,并且可以确认它的效果很好(即我可以使用一个命令调用内部类中的所有测试):

JUnit 4附带了一个名为Enclosed的跑步者类,可以满足您的需求.

使用带有Enclosed = import org.junit.experimental.runners.Enclosed的@RunWith(Enclosed.class)注释外部类;