Contents of .feature file isn't recognized in intelliJ - intellij-idea

I wrote feature files in a project in IntelliJ according to the cucumber syntax. This files worked in another computer. I added the cucumber-java jar files and also installed the Gherkin and cucumber plugins, but still feature files aren't recognized as they should be.
What could be the problem?

So i use IntelliJ 2018
1) go to Preference
2)in open tab search "File Types" and search for text
3) in Text inside "Registred Patterns" delete "*.feature"
4) then search Cucumber Scenario and add "*.feature"

Steps I took to get .feature files recognized. I know that you've probably done this already, but it might help checking the steps again. If all fails, you could try to reinstall the plugins.
Created a new Java project
Created a new file with the .feature extension. Because the plugins were not installed, got the message "Plugins supporting *.feature files found." with the option to install the plugins
I didn't use this option because the suggested plugins were not what I wanted (check below image):
Instead, I've opened Settings > Plugins > Browse Repositories and searched for Cucumber for Java
When trying to install this plugin you will be required to accept the installation of Gherkin as well. Make sure that after accepting, both plugins are selected.
Restart IntelliJ and you should see the feature files recognized:
Hope it helps!

After installing plugin if you till face problem as i did, my feature files are not getting recognized because of groovy
therefore I manually set
File>>Settings>>Editor>>File Types
click "cucumber Scenario" and Click + to add .Feature in Recognize Patterns.

First make sure you have cucumber for java installed, if it is installed follow the below stpes,
1) Create a new feature file, like <test.feature> , after file creation a dialog box pops up
2) Select cucumber scenario in form the list and click Ok, there you GO.

Essentially two things are required to get cucumber feature recognized as expected type.
After adding cucumber-java dependency in pom.xml
You have to add Cucumber plugin also from >
Settings>Plugin>MarketPlace>Search for cucumber for Java and install it
This will also ask you to install Gherkin as a Dependency
Select Yes>> Restart ide
Now you have to change file type from settings >> to cucumber scenario.
Note: you wont be getting Cucumber scenario as recognized type until done above installation.
Select cucumber scenario and Add + wildcard for it as-*.feature

Related

Cucumber with IntelliJ not finding step definitions

I encountered the following issue. I have four Cucumber feature files in IntelliJ. I added the Cucumber support via the IntelliJ plugin. After creating my features I edited my configuration like followed so i can execute the feature files.
Glue should be the name of the package the step definitions reside in. In my case the package is called stepdefinitions.
The following image shows what my project structure looks like. The feature files reside in /src/test/resource/features while the stepdefinitions are stored in /src/test/java/stepdefinitions.
Sadly when I try to run the cucumber features with the step definitions I get prompted "You can implement missing steps with the snippets below:" But I already did this. I already copied those snippets to the step definition files. When I hover a scenario IntelliJ tells me *Unimplemented Substep Definition".
Those two things lead me to the conclusion that IntelliJ does not find my step definitions. Maybe one of you knows what I am doing wrong.
I finally found the solution to my question. The error was caused by a plugin called Substep IntelliJ Plugin. You need to search for it in the IntelliJ Plugin Section and disable or deinstall it.
Try 'Invalidate cache and restart'. It worked for me - something the plugin gets stuck.
Disable the Cucumber plugin to avoid collisions over feature file association, install the Substeps plugin. See http://substeps.github.io/ for more docs on how to use the Substeps BDD framework alongside downloading a sample starter project from here: https://github.com/Substeps/substeps-example/archive/1.1.zip

How to import COM4j as Eclipse Plugin?

I am following the guide shown in https://molteni.wordpress.com/2012/10/16/connect-hp-quality-center-with-java-using-com4j-tutorial/ to generate resources of COM4J.
This is how the COM4J folder looks like
I tried to create an Eclipse plugin based on it and show as below
However when I added the plugin as one of the dependencies of my application I am unable to import the file.
I get the following error when I tried to search it through "Open Type" in Eclipse as follow
What steps am I missing here ?
Usually it is done like this: in Eclipse go to File ->
New -> Plugin Development -> Plugin From Existing Jar Files
Though it might not help in this case: please see this issue: https://java.net/jira/browse/COM4J-57
It sounds like you have not specified which classes are exported by the plugin.
Open the MANIFEST.MF editor for the plugin and select the Runtime tab. In the 'Exported Packages' section click Add and select all the packages which should be available to other plugins.

Launching PHPUnit in PHPStorm for a single instance

I've seen a lot topics about PhpStorm, but they actually got me more confused than I was before.
Basically, my file structure looks like this:
http://i.stack.imgur.com/1nFE2.png
(This is from the Yii 1.1.13 Demo App "Blog")
Now what I want to do is to have these two options:
Choose any of these files -> Right click -> Run (as PHPUnit).
bootstrap.php and phpunit.xml have to be loaded somehow, because
these specify where to load the (Yii) classes needed.
run all tests
within a directory (including subdirectories).
Could anyone point out how to edit the run configuration to achieve this? I already managed to run single tests but the configuration for them were more complicated than to just run them from command line.
Software used:
OS: Mac OS 10.7 Lion, PHPStorm 6, Yii 1.1.13 and PHPUnit 3.7.
You can set your PHPUnit configuration and bootstrap file in the project settings (PHP -> PHPUnit). Now whenever your run a single test, testcase, directory etc. PHPStorm will use your bootstrap.
If you are using Yii, your test classes probably extend from CDbTestCase or CTestCase. PHPStorm does not know that these are tests cases, therefore it doesn't run them with PHPUnit automatically as it should with other tests cases.
What you need to do is setup Yii Framework in your PHP Include Path. You can access this menu by going to External Libraries in the left column of PHPStorm where you see your files. Once you add Yii to your projects PHP Include Path you will see the test files icon changes and has a red and green play like icon.
This means that you will be able to run them and PHPStorm will use your PHPUnit configuration to do so.
For more detailed information on how to configure phpunit with phpstorm check this article:
http://trickortip.com/825/programming/php/phpunit-vagrant-vm-remote-php-interpreter-phpstorm-mac.html/

IntelliJ with cucumber (java) and step definition location

Ok, so I'm working on a project using IntelliJ and trying to take advantage of its cucumber functionality. I've not worked with the java flavour of cucumber, but IntelliJ seems to want the step definition files in a specific location, relative to the feature files.
I found this: how to define step definitions location for cucumber in intelliJ 12 and other sources that pointed me to been able to add the "glue" property of my run configurations which tells cuke which package to find the step file. So I am at a point where I can run my tests via IDEA. BUT I need to set this every time I run a new test, as Ctrl+Alt+F10 or right click+run test will not start the test with this flag. Also, the ide support is screwed as IDEA doesn't know where the steps are, it doesn't auto complte or Ctrl+Click navigate to steps.
Is there a way to the the IDEA project to always look for steps in a given package both when running the tests and for its auto complete?
Creating self answer for others who might have this problem. My project did not have the steps marked as test source root, and although I DID do this, it was not until I closed and reopened my project that they were picked up. So a simple restart was my answer.
You can set the glue location globally by opening "Edit Configurations -> Defaults -> Cucumber Java -> Glue" and add the package names.
(IntelliJ 12.1.4)
Go File->Settings--> plugins
Install Cucumber for Java plugin
Then you can manage cucumber plugin as shown below
This should redirect you to step definition when you click your test.
Hope this helps
IntelliJ supports a plugin for Cucumber-Java/Groovy. Installing this plugin will enable the navigation from Steps mentioned in the feature file to the Step Definitions.
And after creating the Step Definition, navigation is easily possible
I go in EditConfiguration, Glue section and i put the path from the package above and the package where is your class for steps, ex:
CucumberFramework.stepsDefinitions
It is really nonsense :) but in in my case when IDEA refused to add steps definition automatically due to some plugins installed, e.g. Cucumber for Scala and suggested deleting them that i cant since i need them in other project. So, long story short, to add (Create step definition) you need to create Class in 'glue' dir and some fake Cucumber implementation, build one more time and it resolved my issue.
Background:
When I use IDEA 2018.2
And Java 8
And Cucumber info.cukes:cucumber-java:1.2.4
#When("^I created a Class and put there fake step implementation$")
#And("^I run gradle build one more time :)$")
#Then("^This Class will be able for me from the feature file by ALT+ENTER as usual$")
#And("^It resolved my issue when I was not able to automatically generate step definition$")

How can I tell which specific version of JUnit IntelliJ is using?

I've started working on a large project where the IntelliJ environment has already been set up. The environment includes JUnit, and I can successfully run unit tests. I've seen screens where I can specify the usage of JUnit 3 or JUnit 4, but how can I determine which specific JUnit is being used to run my tests, e.g., JUnit 4.11?
I have already tried "Open Module Settings". When I look at the "Dependencies" tab, I don't see anything relating to JUnit, although I can run JUnit tests.
Which jar is used?
When you run JUnit from IntelliJ, the very first line of the console output displays your classpath. You can use Ctrl+F to find any "junit" references.
junit-rt.jar is a helper library that JetBrains might have written. By opening the jar as an archive with 7-zip, you will find that the only package inside it is under com.intellij
According to Java: Which of multiple resources on classpath JVM takes? the first reference to junit.jar is the one you will use.
What version is that jar?
Once you know which jar is being used, there are a number of ways to find the version. One is to use this code taken from https://stackoverflow.com/a/16729507/1405720
import junit.runner.Version;
System.out.println("JUnit version is: " + Version.id());
Another method might be to open up the jar as an archive and see if you can figure it out from there.
If you are looking for the JUnit libraries that are shipped with IntelliJ have a look at the corresponding jars in the lib/ directory of your Intellij IDEA installation.
For more information on this have a look at the online documention:
http://www.jetbrains.com/idea/webhelp/configuring-testing-libraries.html
http://www.jetbrains.com/idea/webhelp/testing.html