Can I avoid running junit tests twice in eclipse when using a TestSuite?

前端 未结 5 1250
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 13:55

I need to do some per-suite initialisation (starting a web-server). It is working fine except that when I run all tests in my project in eclipse my tests run twice. My test

5条回答
  •  借酒劲吻你
    2020-12-16 14:30

    I have an idea for you. Actually you do not want to run these test case as stand-alone test cases. You can do the following.

    Mark the test cases with annotation @RunWith(DoNothingRunner.class)

    Implment DoNothingRunner as following:

    public class DoNothingRunner extends Runner {
        public Description getDescription() {
                  return "do nothing";
            }
        public void run(RunNotifier notifier) {
                // indeed do nothing
            }
    }
    

    I have not tried this personally but I hope this will work.

提交回复
热议问题