Refactor the name of a Cucumber step definition in multiple .feature files in IntelliJ - intellij-idea

Suppose a Cucumber step definition for which I would like to change the name on multiple .feature files.
#Then("^the step which I need to rename in multiple .feature files:$")
I was wondering if there was some IntelliJ plugin support to allow such refactoring.

If you right-click on the step in .feature file there is an option for that: Refactor -> Rename.... But it doesn't work as expected =)
Here is an issue for this: https://youtrack.jetbrains.com/issue/IDEA-152772
Best thing you can do so far is to upvote it...

Related

How to link Feature File to multiple step defintion files in Python BDD

I am developing a framework for automation using pytest-bdd based framework. Based on functionality I have multiple feature files and multiple step defintion files. Some scenarios take steps from other step definition files.
For example I have a Login Module , User Details Module. Now for validation of a step in User Module I do have to start with steps from the Login Module.
However in python bdd, I could see a one to one mapping of feature and step definition file.
Please let me know if this a limitation of pytest bdd framework .
Yes as far as i have worked with pytest bdd, you can only map one step definition to a single feature file, but there are work arounds to these.
1.Use conftest to keep all your common steps that you want to call across multiple feature files.
2.Use methods to be called into other step definitions by importing those methods into other step definitions.
I have a similar experience and i realized that if i don't use 1:1 mapping of feature to step definition file then it results in step_def not found errors
e.g.pytest_bdd.exceptions.StepDefinitionNotFoundError: Step definition is not found:
So, I stick with the safe approach of 1:1 mapping
Would like to hear more thoughts feedback on this

How to rename steps and annotation from Cucumber feature file in IntelliJ?

I've noticed that when renaming a BDD step on a feature file in IntelliJ, I'm asked to create a brand new method rather than having the previous step and annotation renamed. And renaming the step in the definition method before renaming it on the feature file doesn't rename the annotation. Is there anyway to avoid this please so that I can rename all parts involved on the BDD step at once?
Many thanks.
You can avoid this issue by renaming the step in the definition method before renaming it on the feature file.

Can I run/use 3 feature files with a single step definition file in cucumber Java

Can I run/use 3 feature files with a single step definition file in cucumber Java? Does cucumber java supports this?
I have the following feature files:
login.feature
registration.feature
search.feature
I need to implement only 1 step-definition.java file
for the 3 feature files.
You can use as many or as few files as you want to. But I would recommend splitting your step definitions into classes that correspond with the steps. Here are two suggestions as to how you could do it.
login.feature
registration.feature
search.feature
LoginStepDefs.java
RegistrationStepDefs.java
SearchStepDefs.java
or per page
login.feature
registration.feature
search.feature
LoginPageStepDefs.java
RegistrationPageStepDefs.java
SearchPageStepDefs.java
SearchResultPageStepDefs.java
Whatever you choose, make sure your CucumberRunner is configured to pick up the glue code (step definitions).
You can create a step for one feature and if the step makes sense and the logic is the same you can use it on other feature files without creating another step.

Testing with Cucumber and Selenium:How can i break the sequence of feature file and run in random sequence

I have tried many option but any of them not work as i need. I have created some feature file as i required time by time. so i have a disorder feature file.
I want to run the feature file as i wanted. like.
fil1.feature
fil2.feature
fil3.feature
fil4.feature
so i want to run in this sequence : file3.feature->fil4.feature->fil1.feature.
I have tried #tag, #feature in junit test runner option but its maintain the sequence its run only 3,4 but can't run 1.
So can you tell me how to run feature file randomly???
Cucumber picks up the feature files in alphabetic order from the folder given in the features parameter of the CucumberOptions. So one options would be to rename your feature files alphabetically in the order you want.
After the feature files in the initial folder are read, then the sub folders in the location are picked up alphabetically and the feature files inside them are read. So you can place the file you want to be used later into a sub-folder.
Saying all this, it is not a very good idea to have any dependency between tests which requires a sequence to be maintained.
I got the same stop. Have you solved this problem?
I did some test, use --tags #XXX to controll the sequence is useless, it's just action on different scenarios in a feature file.
so far, I have to do it like this cucumber features/c.feature features/a.feature features/b.feature I think this is a little bit better than rename feature files.
But you may say that: "If there is a lot of feature files......" In my project(ROR), I assigned the statement to ./config/cucumber.yml
In cucumber.yml I define a profile, test_dev: features/c.feature features/a.feature features/b.feature after that, I just to use cucumber -p test_dev and the feature files execute in order.
If you have a butter way, please share with us.

I want to create bat file, The Selenium Project is been developed using TESTNG and Java. I have suite in xml.

Now i want to create bat file, Please file in creating bat file.
I don't have main function in my project.
I want to run the test suite in Main class. How can i do that ? Source code please.
You can generate your xml from main function.
I can provide source code, but it is against policy of stackOverflow.
first show your research.
I think many might have answered this.
Hint: use TestNG class
and add XMLTest, XMLSuite and XMLClass objects to it.