cucumber.runtime.CucumberException: No backends were found - java

I am trying to run a BDD test with cucumber in a Maven project.
When I try to run BDDdemo.feature , I get the following error
Exception in thread "main" cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
at cucumber.runtime.Runtime.<init>(Runtime.java:81)
at cucumber.runtime.Runtime.<init>(Runtime.java:70)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Environments
openjdk version : 13.0.1
Apache Maven : 3.6.3
TestNG : 6.14.3
cucumber : 1.2.6
IDE : IntelJ IDEA
dependencies
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.3.0</version>
</dependency>
I have tried the all solutions in stack overflow regarding this issue. But nothing worked for me.
Can anyone help me with this ?

I'm assuming that, according to your pom.xml snippet, you are using TestNG and Junit. Thus, you need to add both cucumber-testng (it's already there) and cucumber-junit (it's missing) as cucumber backends. Please consider adding this other dependency entry to dependencies section on your pom.xml:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.6</version>
</dependency>
PS: all the dependencies you listed seems to be test-scoped, so, consider add <scope>tests</scope> to each one of them to avoid unnecessarily adding those libraries to your final package (in case you are packaging a JAR).

Related

dropwizard + Powermock + Mockito + Maven build error with ClassNotFoundException "ThreadSafeMockingProgress"

For testing static method I am using Power mock and pom.xml entry for this is
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.9</version>
<scope>test</scope>
</dependency>
`
I am running test cases from command prompt which gives me error like
java.lang.RuntimeException: java.lang.ClassNotFoundException: org.mockito.internal.progress.ThreadSafeMockingProgress
at org.powermock.api.support.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:52)
However from Intellij ide, if I run the all test cases(right click on the project + Run "All tests") it works absolutely fine. Does anybody have any idea on this issue?
when you are defining the power mock jars in pom.xml, you don't need to explicitly define dependent jars as incompatible versions may come in the classpath. Use below two versions & remove mockito dependency in you pom.
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.5.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>1.5.4</version>
<scope>test</scope>
</dependency>

IllegalArgumentException on trying out 'Quickstart: Run a Gmail App in Java'

I created a project using maven and followed the steps. But when i run the code i get the following error.
Exception in thread "main" java.lang.IllegalArgumentException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:80)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.<init>(GoogleAuthorizationCodeFlow.java:195)
at com.vertoanalytics.external.mailfetcher.GmailApiQuickstart.main(GmailApiQuickstart.java:41)
When I google it there are some ides about not having latest packges can cause this problem. Here is my meven dependency list related to the project
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-gmail</artifactId>
<version>v1-rev7-1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.18.0-rc</version>
</dependency>
do i miss anything ?

Apache Directory

I am using this doc.
But pom.xml is bit changed (because dependencies from example is not resolved and i have maven error messages), so part of pom.xml i next:
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
<version>2.0.0-M15</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-all</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-integ</artifactId>
<version>1.5.7</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.directory.client.ldap</groupId>
<artifactId>ldap-client-api</artifactId>
<version>0.1</version>
</dependency>
Then I am running test from example i am receiving such error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Class org.apache.directory.server.core.DefaultDirectoryService does not implement the requested interface org.apache.directory.server.core.DirectoryService
at org.apache.directory.server.core.integ.FrameworkRunner.run(FrameworkRunner.java:170)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:77)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
Any ideas?
Test Class: http://pastebin.com/aPisMRSx
Change the version of apacheds-all to the same version as apacheds-core

Drools hello world maven dependencies

I'm trying to run very simple application using Drools and for a couple of hours now can't set up pom.xml with all dependencies.
Here is how it looks now:
<dependencies>
<!-- Drools engine -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
Just like in
https://community.jboss.org/wiki/DroolsMaven
But what I get:
org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.rule.builder.dialect.java.JavaDialectConfiguration:java:org.drools.rule.builder.dialect.java.JavaDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:313)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:298)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:187)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:160)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:26)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:85)
yada-yada-yada
Caused by: java.lang.RuntimeException: The Janino jar is not in the classpath
If I try to add Janino I get another exception about some missing classes(I don't think I should add Janino here anyway as it should be a dependency of something else).
Do I miss anything in my pom?
Thanks!
Leonty
By default, drools-compiler uses the eclipse compiler (JavaDialectConfiguration.ECLIPSE) for the java dialect which is a transitive dependency:
<dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
</dependency>
However, if you prefer the janino compiler(JavaDialectConfiguration.JANINO), you need to add the janino dependency yourself because it is an optional transitive dependency:
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<optional>true</optional>
</dependency>
Look at the droolsjbpm-parent pom to find out which version to use.
Turned out just the right version of Janino is needed for Drools 5.4.0 Final: 2.5.16
Newer versions luck class used in Drools.
<dependencies>
<!-- Drools engine -->
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>5.4.0.Final</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>2.5.16</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>

Unit testing App engine - Eclipse - Maven

For Appengine testing using Eclipse-Maven I have this defined in the POM.xml
<!-- Appengine Testing -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
However, everytime I add this dependency, when my webapp is invoked, it throws this error:
java.lang.ClassCastException: com.google.appengine.tools.development.ApiProxyLocalImpl cannot be cast to com.google.appengine.tools.development.ApiProxyLocal
Although I can run JUnit and test my Appengine specific code, it is very painful that everytime I have to run the app I have to delete these dependencies and refresh everything.
Is there any workaround with this scenario?
I use the same POM as you (#xybrek), I solved this by doing a simple mvn clean gae:run, now it works from maven ...
Which version do you use? My POM doesn't contain appengine-api-labs. Maybe you can try without it:
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>

Categories