0

I am writing a java program where I run junit tests. Currently, the program stops after the junit tests are executed. However, I don't want the program to exit. I can't edit the given junit tests, so I need a way for the program to not quit after they're run. This is the code I use to run a test.

org.junit.runner.JUnitCore.main("Test");

How can I run junit tests without exiting the program?

Matt
  • 181
  • 2
  • 10
  • 2
    Possible duplicate of [Ignore System.exit() from other class](http://stackoverflow.com/questions/1629321/ignore-system-exit-from-other-class) – hinneLinks May 17 '16 at 13:44
  • @Tunaki please review my edits and consider opening this question. – Matt Jun 22 '16 at 12:43

1 Answers1

0

Try using org.junit.runner.JUnitCore.run() method instead of the main method. The run method doesn't call System.exit. You will need to pass in the list of classes rather than the list of class names that you are using for the main method

JUnitCore jUnitCore = new JUnitCore();
junitCore.run(Test.class);
TheEllis
  • 1,666
  • 11
  • 18