I have a project structure:
├── main
│ ├── java
│ │ └── qbs
│ │ ├── QbsApplication.java
│ └── resources
│ ├── application.properties
|
└── test
└── java
└── qbs
└── QbsApplicationTests.java
I have build it with mvn clean:install
and created jar file. Now I want to run the QbsApplicationTests
using the command line.
To do it I have put two jars into one dir:
-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
and executed the following command:
java -cp .:fi.qbs-0.0.1-SNAPSHOT.jar:junit-4.12.jar org.junit.runner.JUnitCore qbs.QbsApplication
However, I keep getting the following error
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
Question:
- How should I run the
QbsApplicationTests
tests form console?
EDIT I have also tried to add the following:
@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);
}
}
to the main class, but Intellij keeps saying that the QbsApplicationTests
cannot be resolved.