# Run JUnit tests cases from java application?

I have some test cases and when I am executing its executing fine.

But  my application requires a lot of work to start launch (lots of dependencies and configurations, etc) and using an external testing tool (like JUnit Ant task) would require a lot of work to set up.

It is easier to start the application and then inside the application run my tests.

So I am looking for a easiest way to run my test cases inside of my java application directly.

Before that first  if remove the dependencies from the code you are testing. The dependencies and configurations are precisely what you are trying to avoid when writing a test framework. For each test, you should be targeting the smallest testable part of an application.

Or else you can go with the below approach,

 JUnitCore junit = new JUnitCore();                                                                                        Result result = junit.run(testClasses);

Please Note : Don't useJUnit.main inside your application, it invokes System.exit after tests are finished and thus it may stop JVM process.