CucumberOptions to execute feature file and Feature Folder using mvn - selenium

I am executing test using tags in the following command:-
mvn test -Dcucumber.options="--tags #smoketest (works fine)
I need to execute test using feature file and Feature folder which is not working
mvn test -Dcucumber.features="C:/Users/xxx/xxx/feature/orders.feature"
(not working, it does not override, i.e it picks up the tag mentioned in option tag )
mvn test -Dcucumber.options="C:/Users/xxx/xxx/feature/orders.feature"
(not working)
mvn test -Dcucumber.options="C:/Users/xxx/xxx/feature"(not working)
I need mvn execution command to run feature file and feature folder
Any help here will be greatly appreciated

Feature files need to be provided after the tags:
mvn test -Dcucumber.options="--tags #smoketest src/test/dev/path/to/feature"
EDIT:
I would use tags in the feature files to run specific features.
If you have features
amazon
harvest
mccoll
Mark each of them with corresponding tags:
#amazon
Feature: Amazon feature
#mccolls
Feature: McColls feature
and provide the path to all features:
mvn test -Dcucumber.options="--tags #amazon,#mccolls src/test/resources/features"
The only disclaimer here is: Be careful how do you provide tags in the command line. There are options for AND, OR, NOT operations. I used Cucumber a few years ago and I don't remember exactly which was which.
I BELIEVE (but be careful) that -t #amazon -t#mccolls is AND operation. Run tests tagged with #amazon AND #mccolls at the same time. So, both tags required.
To run them in OR fashion you'd have to use --tags #amazon,#mccolls
You can try it out with simple trial and error.

Related

Why karate runner file is not run before running the feature files, when running Junit4 Test.java file for tests

Karate suggests that to run all tests in a CI environment, a *Test.java file should be added above the feature files (in hierarchy) and then run using - mvn test command.
I am using my Runner.java file to create test data before the tests are run and then do a clean up. I run this runner file in IDE and everything runs fine - the data is created, all feature files in the same package run and then clean-up is performed. The reason i used the Runner file to create data is because i using karate itself to create test data and the Runner file passes some information on created data to the feature files to run api tests. I had earlier posted a question regarding how to achieve this, please refer to this answer - https://stackoverflow.com/a/55931786/4741035
So now I have a *Test.java file in my project which i run using - mvn test. This runs all the feature files and tests fails as the Runner.java is not executed at all.
Why doesn't karate run the Runner file, if it is present first that the feature files?
Help is much appreciated.
If you are trying to run something "once" before all your tests, use karate.callSingle() documented here: https://github.com/intuit/karate#hooks
var result = karate.callSingle('classpath:demo/headers/common-noheaders.feature', config);
And in the above feature (or JS) you can call Java code using Java interop.
By the way I don't agree with the answer you linked because of the above approaches.

How to target specific Cucumber runner classes or feature files within Jenkins?

Is it possible to target specific runner classes or feature files within Jenkins?
Let's say for example I have the following files.
Runner classes:
RunnerClass1.java
RunnerClass1.java
Feature Files:
Login.feature
SignUp.feature
Is there a way to trigger specific runner classes or feature files within the Jenkins UI, I know you can use specific plugins such as: 'Parameterised / String Parameters', has anyone else found a solution to target specific tests from Jenkins?
thanks for your help
You can tag your test cases and maven will be able to run them by these tags.
For example, When I have Login cases with #Login tags and I want to run them with Maven, I am using the following terminal script :
mvn clean test -Dcucumber.options="--tags #Login"

How to run Clojure tests from clj (not from lein neither boot)?

In a project with the traditional lein project structure, how can I use simply clj to run the tests in the test folder?
Update:
After the mention the REPL, I would like to clarify I'm trying that from the System shell with the clj command. Not from the REPL, neither lein nor boot.
Check out the test-runner from Cognitect. https://github.com/cognitect-labs/test-runner
Once you add the alias, you should be able to run the tests via:
clj -Atest
If you need to configure the directory,
clj -Atest -d path/to/tests
You can run tests from the repl:
; all tests
(clojure.test/run-all-tests)
; all tests in one file
(clojure.test/run-tests 'com.myproject.test.routes.api_test)
; one particular test
(clojure.test/test-vars [#'com.myproject.test.routes.api_test/id-test])
You can find some additional information in official documentation.
And it's very convenient to run tests with cursive plugin in IntelliJ IDEA.

PhantomJS teamcity config

In a teamcity config I have build step which runs PhantomJS tests. It is a "Command Line" step with custom script. The script looks like:
%PhantomJS% CreateEntityPopupTest\unit.htm
%PhantomJS% ExcelImportPopupTest\unit.htm
...
etc.
So it runs each qunit test package mentioned in the htm page. But I didn't manage to find a way to point PhantomJS (phantomjs-1.9.0-windows) to a folder, not to a single file. So there would be no need to change the config each time when we add new files with tests.
I used Chutzpah to wrap this behavior for use in TeamCity. Chutzpah can run tests written in QUnit, Jasmine or Mocha and uses PhantomJS as the headless test runner.
https://github.com/mmanela/chutzpah
I installed it on the build agents and added it to the path on the machine.
Now I simply add a Command line runner step called 'Run JS Test' in my build template. Command line is simply:
chutzpah.console.exe %jsTestFolder%
Then I just define the parameter for each project pointing to a folder... chutzpah does the rest.

Passing the Maven Debug Flag from Hudson

I'm having an issue with a maven build in hudson. This issue would be fairly easy to resolve if I could see the output of maven with the -X flag passed in. However I can't find a way to do this. If I specify "-X" in the "Goals and options" field of the "Build" section in the job configuration my console output looks exactly the same as if I had not passed the "-X" flag at all. Is the debug logging going somewhere else? Or is there some other way I need to pass the "-X" flag?
UPDATE:
The reason this isn't working is because the build is failing during the "Parsing POMs" part of the hudson process, before it actually kicks off the true maven build and passes in any params I specify in the project. So what I really need is a way to get better logging during the "Parsing POMs" part of a maven build in hudson.
That's what it says in the help text.
Specifies the goals to execute, such
as "clean install" or "deploy". This
field can also accept any other
command line options to Maven, such as
"-e" or "-Dmaven.test.skip=true".
I would have put it there as well.
The maven help gives me the following two options:
-X,--debug Produce execution debug output
-e,--errors Produce execution error messages
May be you can try the --debug or the -e swtich
In Jenkins, and I assume this is true for Hudson as well, command line arguments can be passed to Maven in the "goals" setting. I was able to pass the -X parameter by adding it to the beginning of the "goals".
-X package install
Jenkins apparently blindly appends this setting to the end of the mvn command-line.
I have exactly the same problem with Hudson 1.398 (Maven 2.0.10, jdk 1.6.0_07): the build fails during the parsing of the pom files. It works locally and when launched manually from the Hudson workspace.
That build needs an environment variable to be set (for the path of a module), but the environment variable doesn't seem to be propagated from Hudson to Maven. So, like you, I have also tried to get more details from Maven with the -X option, but it also doesn't seem to be propagated.