My Runner class is as below:
#RunWith(CucumberWithSerenity.class)
#CucumberOptions(features = "src/test/resources/features/"
,glue={"com.stepdefs"}
,dryRun=false
,monochrome=true
,plugin = {pretty})
public class Runner {
}
I don't have any issues with executing them using maven. It works totally fine. Only the issue with Eclipse where feature steps can't recognize any step defs. So i can't find them using F3. I have added this below dependency as well:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>gherkin</artifactId>
<version>3.2.0</version>
</dependency>
As well i converted the project to cucumber project, added cucumber plugins in Eclipse. My Eclipse version is 2020-12. Still no luck.
I am using cucumber6, I think this is an existing issue for cucumber 4 and up:
https://github.com/cucumber/cucumber-eclipse/issues/372
https://github.com/cucumber/cucumber-eclipse/issues/368
In my project, I have the class name as part of the definition, e.g:
glue={"com.stepdefs.StepDefinitions"}
Related
I have installed Natural 0.7.6 plug-in from eclipse marketplace and I have Windows 10.
Eclipse version: Eclipse IDE for Java Developers
Version: 2020-03 (4.15.0)
Build id: 20200313-1211
Maven dependencies related to Cucumber:
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
.feature file
step definition file
[1]: [https://i.stack.imgur.com/e22x3.png][1]
[2]: https://i.stack.imgur.com/cAfLY.png
The .feature file complains about "No definition found for ".
CTRL+CLICK on .feature file step is not navigating to stepDefinition file (screenshots attached).
Am I missing any plugin? Is there any compatibility issues with Eclipse IDE version and the Cucumber plug-in I am using? I appreciate your help guys.
Steps to make it work.
Clear out all the cucumber related plugins(e.g. Natural 0.9, cucumber eclipse plugin 1.0.0.xxxxx). Please do follow the suggestion of restarting your eclipse.
Go to Help --> Eclipse Market place --> Install 'cucumber-eclipse' plugin. Please do follow the suggestion of restarting your eclipse.
Right click on your project --> Configure --> Convert to Cucumber project.
Now try to navigate to your step definition by 'Ctrl+click' on test step in feature file
Edit: I also changed JRE system library to 1.8( I am not sure it has any influence to make cucumber work )
I had same problem that CTRL+Click was not working in feature files when I installed Natural plugin in Eclipse IDE.
Later, I uninstalled Natural plugin, and installed "Cucumber Eclipse" plugin, and now I can perform ctrl+click on step name of feature file to navigate to the step definition file.
You can follow below stpes:
Un-install Natural plugin
Install Cucumber Eclipse plugin
Note: Below are my Eclipse version details. "Cucumber Eclipse" plugin may not be available for latest Eclipse version
Version: 2019-06 (4.12.0)
Build id: 20190614-1200
With the Cucumber Eclipse plugin, cleaning the Cucumber project (Project > Clean...) made the Gherkin steps Ctrl+click-able again.
You need a cucumber runner file first and inside that you need to glue the step definition file with the cucumber feature. The thing is that in cucumber if you place the feature file, step definition file and runner file in the same package then automatically, it will be able to map the steps from the step definition file with the feature file. But as per the screenshots, I can see that feature and step definition is present in the different packages. Please create a runner file as shown below
>
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(
features = "<Directory path containing features>"
,glue={"<Step definition package name>"}
) // example: Features: src/test/resources/features, Glue: com.package.name.stepdefs
public class TestRunner {
}
TestRunner.java
If you are not able to get to the relevant step definition method from Feature file by either F3 or CTRL+ Left Mouse Click, change the default editor of Feature file as below
image to select correct Cucumber Editor
I have two project bundles my local CQ/AEM server. Project A contains some java Util class methods which can be utilized in project B as well.
While developing, how do I import my project A classes in project B to access the methods so that I do not have to duplicate the methods again?
I tried adding dependency in my Project B bundle pom.xml as below. Is this correct?
<dependency>
<groupId>com.project-a</groupId>
<artifactId>cq-project-a</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
I get missing artifact error for this.
"Missing artifact com.project-a:cq-project-a:jar:1.0-SNAPSHOT"
Please suggest how the import can be done.
Thanks
I guess you forgot to build project a using mvn install. The dependency will be searched in your local maven repo.
This solution may fix you issue: update your pom.xml on project a, modify groupId, artifactId, version, packaging tags and make sure they look likes:
<groupId>com.project-a</groupId>
<artifactId>cq-project-a</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
Then run mvn clean install on project a, run mvn clean install one more time one project b. I applied this to my last project, I hope it works for you.
I’m using Eclipse Kepler (Java 8). with my Maven (v 3.2.3) project. I’m using JUnit 4.11, as declared in my pom.xml file …
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
I’m trying to run some JUnit tests and I have this at the top of my tests
#FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MyTest
{
However, when I run the test in Eclipse (by right clicking the name of the file and selecting “Run As”, “JUnit Test”), Eclipse is not running the tests in ascending order by name, but instead running the tests one by one as they are listed in the file.
My question is, how can I get Eclipse to respect the “FixMethodOrder” directive in my file? Note that I’m not interested in lectures about why it shouldn’t matter what order you run JUnit tests in.
Open your project build path (right-click on project > Build Path > Configure Build Path...) and go to the Libraries tab. Do you have "JUnit 4" on your Eclipse classpath or just "Maven Dependencies":
Remove it by selecting "JUnit 4" and hitting the remove button to the right. Maven specifies all your dependencies so you don't need Eclipse adding to that.
In my experience Eclipse seems to prefer its own JUnit library at runtime over the JUnit library provided by "Maven Dependencies": I get different results in test execution order between Eclipse and direct Maven when using #FixMethodOrder if the Eclipse "JUnit 4" library is on the classpath, but if I remove that library then Eclipse and Maven are in agreement.
My project which uses Dataflow compiles just fine using
mvn compile
However when I import my project into eclipse, eclipse is unable to build the project and gives the following error
The project was not built since its build path is incomplete.
Cannot find the class file for com.google.common.reflect.TypeToken.
Fix the build path then try building this project
Adding an explicit dependency on Guava to my pom file appears to have fixed the problem.
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>[18.0,)</version>
</dependency>
By running
mvn dependency:tree -Dverbose -Dincludes=com.google.guava
I learned that I had several dependencies that were pulling in Guava so by adding an explicit dependency I was able to force maven to pull in a newer version.
However, I don't know why running 'mvn compile' on the command line worked.
I can run the Java version of my project fine by simply importing Guava libraries like so:
import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;
Following the advice here, I've added this line to html/pom.xml:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>10.0.1</version>
</dependency>
And this line to html/project.gwt.xml file:
<inherits name="com.google.common.collect.Collect"/>
But when I try to GWT-Compile my HTML version in Eclipse, I get errors like the following:
[ERROR] Line 61: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.ImmutableList<E>; did you forget to inherit a required module?
I think you may be importing the wrong class. Try replacing the com.google.gwt.thirdparty.guava.common.collect.ImmutableList import with com.google.common.collect.ImmutableList.
Here is a similar question about the Lists class: Trouble with GWT and Guava
I selected #eneveu's answer as it got me headed in the right direction. Here are more explicit instructions for enabling Guava in the HTML version of your PlayN project.
1. Add dependency to YourGame-core/pom.xml
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>11.0.2</version>
</dependency>
2. Right-click YourGame-core directory in Package Explorer window, then: Maven > Update Dependencies
3. For HTML5, add this line to YourGame-html/YourGame.gwt.xml:
<inherits name="com.google.common.collect.Collect"/>
4. When importing, use the correct library path:
import com.google.common.collect.Foo;
/* NOT: import com.google.gwt.thirdparty.guava.common.collect.Foo; */
I compiled the code at the link below and tested in Chrome to verify that Guava gets imported successfully:
PlaynDev.java