title: How to run JUnit test from within jar while JUnit cannot find the test class
body: <p>I have a project structure:</p>
  
  <pre><code>├── main
  │   ├── java
  │   │   └── qbs
  │   │       ├── QbsApplication.java
  │   └── resources
  │       ├── application.properties
  |
  └── test
      └── java
          └── qbs
              └── QbsApplicationTests.java
  </code></pre>
  
  <p>I have build it with <code>mvn clean:install</code> and created jar file. Now I want to run the <code>QbsApplicationTests</code> using the command line.
  To do it I have put two jars into one dir:</p>
  
  <pre><code>-rw-rw-r--. 1 a a 29M 04-05 10:30 fi.qbs-0.0.1-SNAPSHOT.jar
  -rw-rw-r--. 1 a a  1M 2014-12-04  junit-4.12.jar
  </code></pre>
  
  <p>and executed the following command:</p>
  
  <pre><code>java -cp .:fi.qbs-0.0.1-SNAPSHOT.jar:junit-4.12.jar org.junit.runner.JUnitCore qbs.QbsApplication
  </code></pre>
  
  <p>However, I keep getting the following error</p>
  
  <pre><code>JUnit version 4.12
  .E
  Time: 0,003
  There was 1 failure:
  1) initializationError(org.junit.runner.JUnitCommandLineParseResult)
  java.lang.IllegalArgumentException: Could not find class [qbs.QbsApplication]
      at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:102)
      at org.junit.runner.JUnitCommandLineParseResult.parseArgs(JUnitCommandLineParseResult.java:50)
      at org.junit.runner.JUnitCommandLineParseResult.parse(JUnitCommandLineParseResult.java:44)
      at org.junit.runner.JUnitCore.runMain(JUnitCore.java:72)
      at org.junit.runner.JUnitCore.main(JUnitCore.java:36)
  Caused by: java.lang.ClassNotFoundException: qbs.QbsApplication
      at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:348)
      at org.junit.internal.Classes.getClass(Classes.java:16)
      at org.junit.runner.JUnitCommandLineParseResult.parseParameters(JUnitCommandLineParseResult.java:100)
      ... 4 more
  
  FAILURES!!!
  Tests run: 1,  Failures: 1
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <ul>
  <li>How should I run the <code>QbsApplicationTests</code> tests form console?</li>
  </ul>
  
  <p>EDIT
  I have also tried to add the following:</p>
  
  <pre><code>@SpringBootApplication
  public class QbsApplication {
  
      public static void main(String[] args) {
  
          SpringApplication.run(QbsApplication.class, args);
          System.out.println("Running tests!");
  
          JUnitCore engine = new JUnitCore();
          engine.addListener(new TextListener(System.out) ); // required to print reports
          engine.run( QbsApplicationTests.class);
      }
  
  }
  </code></pre>
  
  <p>to the main class, but Intellij keeps saying that the <code>QbsApplicationTests</code> cannot be resolved.</p>