Setting up cucumber in intellij - java

I'm spinning my wheels trying to run tests in intellij. I'm using the basic framework of a cucumber skeleton project as such.
I have also updated my POM file as such:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MaritProject</groupId>
<artifactId>MaritProject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
</project>
Environment: I am on jdk 1.8 and the JDK has been selected in settings. I've also gone to settings, plug ins and installed the Cucumber for Java plug in. I'm on windows 10.
Requirement: I want to run a basic test of the feature file, which without having anything yet in my runner class, should tell me that zero tests are working and give me the basic output of a step definition file to cut and paste and start fleshing out details in. Then, I want to write and execute the runner file.
Problem: But when I run this feature file, either nothing happens or when I fill out some of the edit configuration, I get "Error running: 'Unnamed: No module defined'. I am following some video tutorials where the run output window looks much different than what I had, so I upgraded my IntellJ to the latest version, 2017.3.5
I have checked the markings on my directory and it looks like Java is correctly marked as Sources under main, java is marked as test Sources under src/test and resources are marked as resources under main and resources root under test. This probably should be all I need, as the video said to do even less than this. When I run mvn clean test in the directory of my project, I get BUILD SUCCESS back.
But, since I upgraded IntelliJ in attempt to correct a different issue, now I cannot run any feature or class file. It wants me to edit my configurations first. These configurations include a main class, glue, feature or folder path, VM options, program arguments, working directory, environment variables and classpath of module. This window was not there previously when I tried to run. I don't know what to put in any of these input boxes and google results have so far been unhelpful. How do I tell what my main class is or what the glue is? Glue looks like a required field, but I don't know what path corresponds to the glue. I can guess that my working directory is where the files are stored. I have my java and maven home environment variables saved on my machine, but do I also need them in intellij?

I have had some troubles getting this stuff to work. For this configuration works:
<properties>
<java.version>1.8</java.version>
<junit.version>4.12</junit.version>
<cucumber.version>1.2.5</cucumber.version>
<maven.compiler.version>3.3</maven.compiler.version>
</properties>
<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java8</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Note that I have the versions specified a inside , they could also be provided inline.
Other than that you have to specify glue. This is the directory where your stepDefinition files are. Your glue and features and so on can be specified in a testrunnerclass or something like that. However note that this class HAS TO HAVE "Test" in the name. Something like TestRunner or CukesRunTest will do. RunnerClass will not be recognized.

Please remove
<!-- https://mvnrepository.com/artifact/info.cukes/cucumber-java -->
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
as you have two versions of cucumber currently in your pom.xml

Related

Hamcrest Matcher signer information does not match signer information of other classes in the same package

I'm trying to write some integration tests in my Spring Boot application using REST-Assured and JUnit5 but when I run the following:
#SpringBootTest(classes = ProductsApplication.class)
class ProductsApiTest {
#Before
public void setup() {
RestAssured.baseURI = "http://localhost:8080/test/api/products";
}
#Test
public void test1() {
ValidatableResponse statusCode = given().when().get().then().statusCode(200);
}
}
A nasty error comes up:
java.lang.SecurityException: class "org.hamcrest.Matchers"'s signer
information does not match signer information of other classes in the
same package
Please take a look at my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
...
<dependencies>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<scope>test</scope>
</dependency>
...
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
</dependency>
</dependencies>
<build>
...
</build>
</project>
Here are the Order and Export + the Libraries the Eclipse project uses:
How do I set up the Eclipse environment to work with REST-Assured and Hamcrest? Why would this exception be thrown?
I deleted the org.hamcrest.core_1.3.0.v201303031735.jar from my .p2 plugins folder and it worked for me.
I searched for "hamcrest" in "C:\Users\Dell.p2\pool\plugins" folder and found "org.hamcrest.core_1.3.0.v201303031735.jar" there.
I deleted it for this path.
Tried to run the test cases and it got passed with no failure in statusCode() method line.
Please suggest if anyone has a better solution.
In my case, the problem was solved by adding an explicit dependency to Hamcrest at the top of the dependency list in my pom.xml:
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
This issue can also occur within Eclipse plugin development if you define your own dependency on a later version of hamcrest.
I worked around this by removing the hamcrest plugin from the platform definition:
Select Windows -> Preferences -> Plugin Development -> Running Platform -> Edit -> Content
Filter for "hamcrest"
Untick org.hamcrest.core
If you get this error in eclipse the problem is that eclipse already has a hamcrest-core library in its plugins folder which has priority over your maven hamcrest library.
What you can do is overwrite the eclipse one (careful to have the same version with the one you have in your maven repositories folder). I am using hamcrest-core 1.3.
I'll show the steps for MacOS but should be similar on Windows you just need to find the eclipse plugins folder and maven repositories folder on your own machine.
Close Eclipse.
Go to Eclipse plugins folder (on MacOS: ~/.p2/pool/plugins)
Find your hamcrest-core library (for me: org.hamcrest.core_1.3.0.v20180420-1519.jar)
Make a backup so that you can revert it - rename the file with a different extension (ex: org.hamcrest.core_1.3.0.v20180420-1519.bck)
Copy from the maven repositories (on MacOS: ~/.m2/repository) the hamcrest-core library into the plugins folder with the same name (on MacOS: cp ~/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar org.hamcrest.core_1.3.0.v20180420-1519.jar)
Open Eclipse and run the test, the test should now run correctly.
In my case I just removed the Eclipse's JUnit5 library from classpath.

JUnit5 comparing two ArrayLists results in No tests Found with test runner [duplicate]

The problem
Whenever I run my projects JUnit test (using JUnit 5 with Java 9 and Eclipse Oxygen 1.a) I encounter the problem that eclipse can't find any tests.
The description
Under the run configuration, eclipse can't even find the method which is annotated with #Test, but instead only shows me "(all methods)".
The following picture hopefully gives a better glimps of my setup:
Console output:
java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:31)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.base/java.lang.Class.newInstance(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:368)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:363)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:307)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:222)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.core.LauncherFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
What I tried so far
I've already tried
to remove the test folder from build path and add it again.
to start the test with hovering over the method annotated with #Test and then click "Run as JUnit Test".
remove JUnit from Buildpath and add it again
restart eclipse
I've also moved the project whole project from one machine to another machine and tried it with the provided eclipse installation there
to rename the test method.
to retype the #Test annotation
Some of these steps can be found here, but in the end the problem remained.
I fixed the issue by right clicking the test and selecting 'Run Configurations' and changing the "Test runner:" selection to 'JUnit 4' as shown here:
I ran the test again and it worked.
I have the same issue with STS 3.9.1. It seems like an Eclipse bug, however, to fix this you can add a test dependency junit-platform-launcher to your project (https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher)
This is how I did for my project which uses gradle:
dependencies {
// other stuff here
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.${junit5MinorVersion}"
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.${junit5MinorVersion}"
}
gradle.properties file:
junit5MinorVersion=1.0
I believe the same applies if you see this exception while using IntelliJ IDEA.
In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.
So do NOT import this one:
import org.junit.Test // JUnit 4
But DO import that one:
import org.junit.jupiter.api.Test // JUnit 5
SIMPLE FIX: (Add JUnit 5 Library)
INSTRUCTIONS:
Right click on project -> Build Path -> Configure Build Path
In the pop-up -> Add Library -> JUnit -> JUnit 5 -> Finish -> Apply
You should see the JUnit 5 Library (and its jars) added to your project
Right click on project -> Maven -> Update Project -> OK
You ran into Eclipse bug 525948 which has already been fixed and which will be published in the upcoming release Oxygen.3 (4.7.3), March 21, 2018.
As workaround, put your test code in a separate project and add the project under test to the modulepath, but do not add a module-info.java to your test project. With your project, class and module naming, it should look something like this:
See also my video that shows Java 9 and JUnit 5 in Eclipse Oxygen.1a in action
Answers so far did not adress the problem of sharing code with other people who don't necessarily use Eclipse. Here is one proposition. The key is to use a maven profile to solve the Eclipse Case.
It assumes you have defined a property junit5.version in your pom like:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit5.version>5.1.1</junit5.version>
</properties>
then in the profiles section add the following:
<profiles>
<profile>
<id>eclipse</id>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
All you have to do after this is to select the profile in your local Eclipse: Right click on your project and select Maven > Select Maven Profiles... (or hit Ctrl + Alt + P), and then check the "eclipse" profile we just created.
With that you are done. Your Eclipse will run Junit 5 tests as expected, but the configuration you added won't pollute other builds or other IDE
Adding this maven dependency with JUnit Jupiter (v.5.5.1) solves the issue.
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
FYI, another cause of "No tests found using junit5" is (inadvertently or intentionally) declaring the test cases "private":
// Example of test case that doesn't get included
#Test
private void testSomeMethod() {
}
They need to be public.
I use actually spring-tool-suite-4-4.5.1 and I had this bug when I want run a test class.
and the solution was to add to 'java build path', 'junit5' in Libraries
None of the solutions helped:
The problem is that Eclipse 2018-12 has support for JUnit 5.3.1. If you start it with a version before that, it will fail.
So make sure you use at least 5.3.1.
5.4.0 does work too.
In case your parent pom is Spring Boot, you need to make sure (in dependency management) that junit-jupiter-api is set to the same version. You don't need junit-platform-runner or -launcher!
Following Andrii Karaivanskyi's answer here's the Maven POM declaration:
<properties>
...
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-platform.version>1.2.0</junit-platform.version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
...
</dependencies>
UPDATE
As per comment by Alexander Wessel you can use org.junit:junit-bom as described in his answer to question Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory.
I also faced the same issue you just need to add the library , Junit Library is already provided along with Eclipse so you just need to follow below
Build Path > Configure Build Path > library > Add library > JUnit > Next > finish
It works for me
From the start the error message tell you that class is not found : NoClassDefFoundError that mean the PATH to junit is the problem.
Press right click to project folder and choose Properties OR select project folder and press combination cmd + i.
select from list "Java Build Path".
select "Libraries" tab
If JUnit 5(or JUnit 4) is added to "Modulepath", select the "JUnit 5" and press Remove.
select "Classpath", press "Add Library...".
from opened "Add Library" window, select JUnit, press next.
Select JUnit library version that you need and press Finish.
That is all. Try to run test again.
replace:
import org.junit.Test;
with:
import org.junit.jupiter.api.Test;
I got the same problem after creating a new TestCase: Eclipse -> New -> JUnit Test Case. It creates a class without access level modifier. I could solve the problem by just putting a public before the class keyword.
As everyone informed it's IDE bug, I tried in Eclipse and STS. In both the cases, it is failing.
As a workaround, I have fixed by modifying the pom.xml file like below.
I have added these two maven dependencies junit-jupiter-engine and junit-platform-launcher.
pom.xml
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Also please make sure to add the version of both the maven dependencies in the properties tag.
<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-platform.version>1.2.0</junit-platform.version>
</properties>
you should know that :
#Before from junit4 goes with #Test : "import org.junit.Test"
AND
#BeforeEach from Junit5 goes with : "import org.junit.jupiter.api.Test"
so make sure you are using the imports from the same version of Junit , otherwise it w'ont Work I guess.
#Test annotation must be imported from org.junit.jupiter.api.Test so the Junit5 can read it.
Junit4 use #Test annotations imported from org.junit.Test package.
Using STS 3.9.1 I got the same problem. However, currently I do not require any new JUnit5 features, so I tried to force using an older version. If using maven, you can add following dependencies to your pom.xml:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
This did the trick for me (at least as long as I do not need JUnit5 explicitly).
I am using eclipse 2019-09.
I had to update the junit-bom version to at least 5.4.0. I previously had 5.3.1 and that caused the same symptoms of the OP.
My config is now:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.5.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
You are missing JUnit 5 platform launcher with group: 'org.junit.platform', name: 'junit-platform-launcher'
Just add in ur POM:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
Since it's not possible to post code blocks into comments here's the POM template I am using in projects requiring JUnit 5. This allows to build and "Run as JUnit Test" in Eclipse and building the project with plain Maven.
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project name</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- only required when using parameterized tests -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
You can see that now you only have to update the version in one place if you want to update JUnit. Also the platform version number does not need to appear (in a compatible version) anywhere in your POM, it's automatically managed via the junit-bom import.
You can use only junit-jupiter as a test dependency instead of junit-jupiter-api, junit-platform-launcher, junit-jupiter-engine.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
I'm using:
Spring Tool Suite 4
Version: 4.4.2.RELEASE
Build Id: 201911201053
Java version: 1.8.0_191
and the message displayed is
No tests found with test runner 'JUnit5'
what worked for me was the configuration below
<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<junit-platform.version>1.5.2</junit-platform.version>
</properties>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
You might be importing #Test from org.junit.Test, which is a JUnit 4 annotation. The Junit5 test runner will not discover it.
The Junit5 test runner will discover a test annotated with org.junit.jupiter.api.Test
Found the answer from Import org.junit.Test throws error as "No Test found with Test Runner "JUnit 5""
You should make sure your test case function is public rather than private to make it accessible by Test Runner.
#Test
private void testmethod(){}
to
#Test
public void testmethod(){}
Same error i faced in eclipse version Oxygen.3a Release (4.7.3a) . There is issue in Maven Dependencies mismatch.To solve i have updated my Pom.xml with following dependecies.
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.netapp.junitnmactiopractice
JunitAndMactioPractice
0.0.1-SNAPSHOT
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.1.1</junit.jupiter.version>
<junit.platform.version>1.1.1</junit.platform.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
you should change
#Test
public static void testmethod(){}
to
#Test
public void testmethod(){}
the #Test is unsupport static method
For me, I configured the build path to add JUnit 5 Library and also by adding the dependency
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
seperately.
I faced this issue with Eclipse (Version: 2019-12 (4.14.0)) too. The solution seems either to use IntelliJ or to use the Maven test to run such tests in Eclipse.

Configuring Geb and Spock with Maven in Eclipse

Disclaimer: I've gone through so many different sources before I came here to ask this question. I've referenced the GitHub project for geb with maven, book of geb, numerous YouTube tutorials, etc. Nothing has worked.
I'm simply trying to just get a project up and running that does a very simple automated search engine test, just so I can play with the tools.
Here is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>nope</groupId>
<artifactId>nope</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testing this</name>
<description>testing this</description>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.spockframework/spock-core -->
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.1-groovy-2.4</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.13</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.gebish/geb-spock -->
<dependency>
<groupId>org.gebish</groupId>
<artifactId>geb-spock</artifactId>
<version>2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.9.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.9.1</version>
</dependency>
</dependencies>
</project>
Main Groovy test class:
package com.na.tests
import spock.lang.Specification
import geb.*
class MyBaseTests extends Specification {
def "search 'Groovy Browser Automation' in duckduckgo"() {
given: "we are on the duckduckgo search-engine"
go "http://duckduckgo.com"
when: "we search for 'Groovy Browser Automation'"
$("#search_form_homepage").q = "Groovy Browser Automation"
$("#search_button_homepage").click()
then: "the first result is the geb website"
assert $("#links").find(".links_main a", 0).attr("href") == "http://www.gebish.org/"
}
}
This is the exception I get in the test. I've run a really simple assert Hello World test that has passed, I eliminated that for the sake of clarity.:
groovy.lang.MissingMethodException: No signature of method:
com.na.tests.MyBaseTests.go() is applicable for argument types:
(java.lang.String) values: [http://duckduckgo.com] Possible solutions:
is(java.lang.Object), Mock(), Spy(), any(), grep(),
Mock(groovy.lang.Closure) at com.na.tests.MyBaseTests.search 'Groovy
Browser Automation' in duckduckgo(MyBaseTests.groovy:22)
Edit
It's worth noting that in my IDE (Eclipse), it seems some of the keywords are either not recognized or are not legit (ie: go "http://duckduckgo.com"). Makes me feel like I haven't configured something.
You need to extend geb.spock.GebSpec and not Specification if you want to use geb. See also gebish.org/manual/current/#spock-junit-testng
On GitHub I have a set of three Maven projects which together set up Spock, Geb and multi-browser testing via Maven configuration. You can switch the browser used easily among HtmlUnit, PhantomJS, Chrome, Firefox, IE, Edge, Opera. It comes with a small series of sample tests and a prepared Geb configuration:
Maven BoM
Test resources
Sample tests
Just clone and build them all mvn clean install in the order listed here and run the tests from the third. You can, of course, put everything into one module, but I think it makes more sense to keep version management and dependency management separate from the actual application so as to be able to re-use those test dependencies, as is good Maven practice.
Update:
Then just add your test to the sample project and run it. I renamed the class so as to end with *Test instead of *Tests because this is how Maven by default finds unit tests via Surefire. If you rather like it to run as an integration test because it opens a browser and basically is slow, rename it to *IT.
I also fixed the base class as Leonard suggested correctly and changed the explicit to an implicit assert.
package com.na.tests
import geb.spock.GebSpec
class MyBaseTest extends GebSpec {
def "search 'Groovy Browser Automation' in duckduckgo"() {
given: "we are on the duckduckgo search-engine"
go "http://duckduckgo.com"
when: "we search for 'Groovy Browser Automation'"
$("#search_form_homepage").q = "Groovy Browser Automation"
$("#search_button_homepage").click()
then: "the first result (excluding ads) is the geb website"
$("#links").$(".links_main a", 0).attr("href") == "http://www.gebish.org/"
}
}

Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory

The problem
Whenever I run my projects JUnit test (using JUnit 5 with Java 9 and Eclipse Oxygen 1.a) I encounter the problem that eclipse can't find any tests.
The description
Under the run configuration, eclipse can't even find the method which is annotated with #Test, but instead only shows me "(all methods)".
The following picture hopefully gives a better glimps of my setup:
Console output:
java.lang.NoClassDefFoundError: org/junit/platform/launcher/core/LauncherFactory
at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:31)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.base/java.lang.Class.newInstance(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:368)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:363)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:307)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:222)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.core.LauncherFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
What I tried so far
I've already tried
to remove the test folder from build path and add it again.
to start the test with hovering over the method annotated with #Test and then click "Run as JUnit Test".
remove JUnit from Buildpath and add it again
restart eclipse
I've also moved the project whole project from one machine to another machine and tried it with the provided eclipse installation there
to rename the test method.
to retype the #Test annotation
Some of these steps can be found here, but in the end the problem remained.
I fixed the issue by right clicking the test and selecting 'Run Configurations' and changing the "Test runner:" selection to 'JUnit 4' as shown here:
I ran the test again and it worked.
I have the same issue with STS 3.9.1. It seems like an Eclipse bug, however, to fix this you can add a test dependency junit-platform-launcher to your project (https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher)
This is how I did for my project which uses gradle:
dependencies {
// other stuff here
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: "5.${junit5MinorVersion}"
testCompile group: 'org.junit.platform', name: 'junit-platform-launcher', version: "1.${junit5MinorVersion}"
}
gradle.properties file:
junit5MinorVersion=1.0
I believe the same applies if you see this exception while using IntelliJ IDEA.
In my case, the problem was myself and no IDE like Eclipse. I've imported the JUnit 4 Test class.
So do NOT import this one:
import org.junit.Test // JUnit 4
But DO import that one:
import org.junit.jupiter.api.Test // JUnit 5
SIMPLE FIX: (Add JUnit 5 Library)
INSTRUCTIONS:
Right click on project -> Build Path -> Configure Build Path
In the pop-up -> Add Library -> JUnit -> JUnit 5 -> Finish -> Apply
You should see the JUnit 5 Library (and its jars) added to your project
Right click on project -> Maven -> Update Project -> OK
You ran into Eclipse bug 525948 which has already been fixed and which will be published in the upcoming release Oxygen.3 (4.7.3), March 21, 2018.
As workaround, put your test code in a separate project and add the project under test to the modulepath, but do not add a module-info.java to your test project. With your project, class and module naming, it should look something like this:
See also my video that shows Java 9 and JUnit 5 in Eclipse Oxygen.1a in action
Answers so far did not adress the problem of sharing code with other people who don't necessarily use Eclipse. Here is one proposition. The key is to use a maven profile to solve the Eclipse Case.
It assumes you have defined a property junit5.version in your pom like:
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit5.version>5.1.1</junit5.version>
</properties>
then in the profiles section add the following:
<profiles>
<profile>
<id>eclipse</id>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
All you have to do after this is to select the profile in your local Eclipse: Right click on your project and select Maven > Select Maven Profiles... (or hit Ctrl + Alt + P), and then check the "eclipse" profile we just created.
With that you are done. Your Eclipse will run Junit 5 tests as expected, but the configuration you added won't pollute other builds or other IDE
Adding this maven dependency with JUnit Jupiter (v.5.5.1) solves the issue.
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.5.1</version>
<scope>test</scope>
</dependency>
FYI, another cause of "No tests found using junit5" is (inadvertently or intentionally) declaring the test cases "private":
// Example of test case that doesn't get included
#Test
private void testSomeMethod() {
}
They need to be public.
I use actually spring-tool-suite-4-4.5.1 and I had this bug when I want run a test class.
and the solution was to add to 'java build path', 'junit5' in Libraries
None of the solutions helped:
The problem is that Eclipse 2018-12 has support for JUnit 5.3.1. If you start it with a version before that, it will fail.
So make sure you use at least 5.3.1.
5.4.0 does work too.
In case your parent pom is Spring Boot, you need to make sure (in dependency management) that junit-jupiter-api is set to the same version. You don't need junit-platform-runner or -launcher!
Following Andrii Karaivanskyi's answer here's the Maven POM declaration:
<properties>
...
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-platform.version>1.2.0</junit-platform.version>
...
</properties>
<dependencies>
...
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
...
</dependencies>
UPDATE
As per comment by Alexander Wessel you can use org.junit:junit-bom as described in his answer to question Eclipse No tests found using JUnit 5 caused by NoClassDefFoundError for LauncherFactory.
I also faced the same issue you just need to add the library , Junit Library is already provided along with Eclipse so you just need to follow below
Build Path > Configure Build Path > library > Add library > JUnit > Next > finish
It works for me
From the start the error message tell you that class is not found : NoClassDefFoundError that mean the PATH to junit is the problem.
Press right click to project folder and choose Properties OR select project folder and press combination cmd + i.
select from list "Java Build Path".
select "Libraries" tab
If JUnit 5(or JUnit 4) is added to "Modulepath", select the "JUnit 5" and press Remove.
select "Classpath", press "Add Library...".
from opened "Add Library" window, select JUnit, press next.
Select JUnit library version that you need and press Finish.
That is all. Try to run test again.
replace:
import org.junit.Test;
with:
import org.junit.jupiter.api.Test;
I got the same problem after creating a new TestCase: Eclipse -> New -> JUnit Test Case. It creates a class without access level modifier. I could solve the problem by just putting a public before the class keyword.
As everyone informed it's IDE bug, I tried in Eclipse and STS. In both the cases, it is failing.
As a workaround, I have fixed by modifying the pom.xml file like below.
I have added these two maven dependencies junit-jupiter-engine and junit-platform-launcher.
pom.xml
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform launcher -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Also please make sure to add the version of both the maven dependencies in the properties tag.
<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-platform.version>1.2.0</junit-platform.version>
</properties>
you should know that :
#Before from junit4 goes with #Test : "import org.junit.Test"
AND
#BeforeEach from Junit5 goes with : "import org.junit.jupiter.api.Test"
so make sure you are using the imports from the same version of Junit , otherwise it w'ont Work I guess.
#Test annotation must be imported from org.junit.jupiter.api.Test so the Junit5 can read it.
Junit4 use #Test annotations imported from org.junit.Test package.
Using STS 3.9.1 I got the same problem. However, currently I do not require any new JUnit5 features, so I tried to force using an older version. If using maven, you can add following dependencies to your pom.xml:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.vintage.version}</version>
<scope>test</scope>
</dependency>
This did the trick for me (at least as long as I do not need JUnit5 explicitly).
I am using eclipse 2019-09.
I had to update the junit-bom version to at least 5.4.0. I previously had 5.3.1 and that caused the same symptoms of the OP.
My config is now:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.5.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
You are missing JUnit 5 platform launcher with group: 'org.junit.platform', name: 'junit-platform-launcher'
Just add in ur POM:
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
</dependency>
Since it's not possible to post code blocks into comments here's the POM template I am using in projects requiring JUnit 5. This allows to build and "Run as JUnit Test" in Eclipse and building the project with plain Maven.
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project name</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.3.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- only required when using parameterized tests -->
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
You can see that now you only have to update the version in one place if you want to update JUnit. Also the platform version number does not need to appear (in a compatible version) anywhere in your POM, it's automatically managed via the junit-bom import.
You can use only junit-jupiter as a test dependency instead of junit-jupiter-api, junit-platform-launcher, junit-jupiter-engine.
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
I'm using:
Spring Tool Suite 4
Version: 4.4.2.RELEASE
Build Id: 201911201053
Java version: 1.8.0_191
and the message displayed is
No tests found with test runner 'JUnit5'
what worked for me was the configuration below
<properties>
<java.version>1.8</java.version>
<junit-jupiter.version>5.5.2</junit-jupiter.version>
<junit-platform.version>1.5.2</junit-platform.version>
</properties>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-platform.version}</version>
<scope>test</scope>
</dependency>
You might be importing #Test from org.junit.Test, which is a JUnit 4 annotation. The Junit5 test runner will not discover it.
The Junit5 test runner will discover a test annotated with org.junit.jupiter.api.Test
Found the answer from Import org.junit.Test throws error as "No Test found with Test Runner "JUnit 5""
You should make sure your test case function is public rather than private to make it accessible by Test Runner.
#Test
private void testmethod(){}
to
#Test
public void testmethod(){}
Same error i faced in eclipse version Oxygen.3a Release (4.7.3a) . There is issue in Maven Dependencies mismatch.To solve i have updated my Pom.xml with following dependecies.
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.netapp.junitnmactiopractice
JunitAndMactioPractice
0.0.1-SNAPSHOT
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.1.1</junit.jupiter.version>
<junit.platform.version>1.1.1</junit.platform.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
you should change
#Test
public static void testmethod(){}
to
#Test
public void testmethod(){}
the #Test is unsupport static method
For me, I configured the build path to add JUnit 5 Library and also by adding the dependency
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
seperately.
I faced this issue with Eclipse (Version: 2019-12 (4.14.0)) too. The solution seems either to use IntelliJ or to use the Maven test to run such tests in Eclipse.

Maven install succeeds, but jar doesn't work correctly from bash (CLI)

currently I'm working on a project in my company that imports XML data to our database. While doing this I rely on some basic configuration projects which have been already created and used in other Projects, i.e. an EntityManagerBuilder or other utility classes that are used in order to create a connection to our oracle database. And it seems to me that those dependencies are creating some problems for me.
My project runs perfectly fine if I start it within eclipse. And when I create the project with mvn clean install -DskipTests it builds all fine.
But when I want to run it from the command line the application starts and after a few lines of code just stops, without throwing any errors or exceptions.
The reason why I think that it has something to do with some dependencies is that by logging I managed to find the point where the application stops. Since it stopped at a point I could investigate, I just did that. I downloaded the sources an only added some logging and suddenly my application had no problems at all with that class, instead it just stopped with the next static call to an other class.
I have no idea at all where to search for the error. Since this is an application that has to run by it self as a monthly task, executing it from eclipse is not an option.
Hopefully someone can give me a hint how to solve this.
Here is my POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.company.infrastructure.foo</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>foo-import</artifactId>
<packaging>jar</packaging>
<name>FooImport</name>
<properties>
<company.consoleapp.main.class>com.company.infrastructure.foo.import.FooImporter</company.consoleapp.main.class>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.company.maven</groupId>
<artifactId>company-standalone-dm</artifactId>
<version>${company.parent.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<!-- Utilities -->
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<!-- Using foo-dataaccess -->
<dependency>
<groupId>com.company.infrastructure.marken</groupId>
<artifactId>foo-dataaccess</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>foo-import</finalName>
<plugins>
<!-- Consoleapp-Mixin -->
<plugin>
<groupId>com.github.odavid.maven.plugins</groupId>
<artifactId>mixin-maven-plugin</artifactId>
<configuration>
<mixins>
<mixin>
<groupId>com.company.maven</groupId>
<artifactId>company-consoleapp-mixin</artifactId>
<version>${company.parent.version}</version>
</mixin>
</mixins>
</configuration>
</plugin>
</plugins>
</build>
I think this might be something to do with your dependency management in maven, since you haven't specified the versions and maven figures out those versions automatically.
However when you run the application, you need those jars to be in your classpath otherwise you might end up getting a ClassNotFoundException because the jars are not available. So unless you figure out what your dependencies are like you mentioned and add them to your classpath you would end up seeing the error.
It might be worth enabling a further level of logging in your application to give you some indication of where the error is. You could also try and see if at the point of failure is referenced to an external library, which is the one that is not available in your classpath.
Could you also please share how your running your application through CLI.

Categories