Running a single .feature file [duplicate] - karate

This question already has an answer here:
Unable to use read('classpath:') when running tests with standalone karate.jar
(1 answer)
Closed 1 year ago.
I'd like to run a single .feature file, the one I'm trying to debug, instead of the full set of over 100 tests we have... it it possible?
I'v tried adding the "classpath" to the karate options, as I saw in other answers, but it still runs everything even if the path doesn't exists:
$ mvn clean test \
-Dtest=ParallelTest \
-DargLine="-Dkarate.options='--tags ~#ignore classpath:relative/path/to/my/new.feature" \
-Denv='dev'

This is what the IDE support is for, we have Visual Studio Code (recommended), IntelliJ and Eclipse: https://github.com/intuit/karate/wiki/IDE-Support
If you are interested in the details, there is a "CLI way" to do this (0.9.5 onwards): https://github.com/intuit/karate/wiki/Debug-Server#maven - so just put a feature classpath: instead of the -d
And for Maven / JUnit users, most teams write a "Runner" class, and you can add a test method and run a single feature, please refer to the docs: https://github.com/intuit/karate#junit-5

Related

After building a Kotlin program in IntelliJ, how do I execute it directly from the terminal? [duplicate]

I have installed IntelliJ IDEA on my mac and wrote the simplest Kotlin program
fun main(args : Array<String>){
println("Hello")
}
I can run it from the IDE environment. (It prints Hello of course)
My question: How can you run this from the console?
What I have done:
I tried to call
java simplekt.class
but I got
Error: could not find or load main class simplekt.class
I tried java simplekt but then I got an exception in thread main java.lang.NoClassDefFoundError
I tried to use kotlin or kotlinc but the command was not found. (where is the compiler installed?)
In this resource they use kotlinc and they produce a jar file but IDEA only output a class file.
Not really sure how to proceed from here.
When you run your application from the IDE, in the Run window the very first line is the command that the IDE executes to start your program. In my case it's something like:
/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home/bin/java -Dfile.encoding=UTF-8 <a lot more omitted>
You can execute the same command in your terminal and that will execute the application. Reading that line will also (indirectly) tell you where the kotlinc command is installed, and in my case – using MacOS – it's at /Applications/IntelliJ\ IDEA.app/Contents/plugins/Kotlin/kotlinc/bin/kotlinc
However, you can always decide to entirely stop using the IDE and compile/run your program from the command line by following instructions here: https://kotlinlang.org/docs/tutorials/command-line.html
The above answer by #user2340612 is mostly right, but maybe due to software changing or some differences in what i did, it did not work for me. Following did:
to avoid repetition, i'll be using the short name: $(ideac) = "IntelliJ IDEA Community Edition 2022.2" in place of the full name
the path to the kotlinc is this one: $(ideac)\plugins\Kotlin\kotlinc\bin
much similar to the one told above, but slightly different
i have verified it to work in the command given in the command-line doc linked above or compiler-reference too: kotlinc hello.kt -include-runtime -d hello.jar
running the resultant .jar file via java -jar ./hello.jar shows the expected output
there's no kotlin-native in that folder, so, couldn't verify this native-command-line-compiler kotlin doc
Backstory/What did not work
the command under the run tab in $(ideac) no longer shows the kotlinc path
I had created the Kotlin "project" by using "new project" (intelliJ) or by "Kotlin multiplatform > JVM" (gradle)
The run command for either of these did not contain any kotlinc in them
I tried creating a new > "scratch" file; and it showed this: $(ideac)\plugins\Kotlin\bin\windows\LLDBFrontend.exe but i tried using that on CLI and it did not work either

Karate run through mvn terminal - Nashorn is null [duplicate]

This question already has answers here:
Karate karate-config.js not a js function
(2 answers)
Closed 2 years ago.
I have a karate 0.9.9.RC3 project with Java 15, tests run correctly if running directly through runner, however if I chose to run through 'mvn test' I get 'nashorn is null' error.
Sounds like you have multiple dependencies in your pom.xml file. Follow this process please: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

How to limit the report generation only for specific feature file in karate framework?

I am having 3 feature file and I am trying to execute specific feature in karate using
#CucumberOptions(features = "classpath:Karate/Karate/APIM_LAYER.feature") over the test runner class.
But on execution, we are able to find reports for all the 3 feature files present in the "target/sure-fire reports path".
Please let us know is there a way to resolve this issue.
You should upgrade to V0.6.2, and when you run with #RunWith(Karate.class) with Cucumber options it will run those files sequentially and generate pretty html reports for each feature file.
As for the location of the reports, its usually mentioned in the console/terminal.
So make a testfolderunner.java file. add your cucumber options and then from terminal do mvn test -D test=testfolderunner
Al the best
I'm sure you still have the #RunWith(Karate.class) annotation even though it is clearly mentioned in the documentation that you should NOT use it for the parallel runner. Please confirm.

How to set System property in JMeter selenium? [duplicate]

This question already has answers here:
How to create and run Apache JMeter Test Scripts from a Java program?
(5 answers)
Closed 2 years ago.
Im Using Selenium with JMeter's WebDriver Sampler and I want to test my app in Internet Exoplorer buy when I run it I got this error:
java.lang.IllegalStateException: The driver executable does not exist: C:\Users\PNB01\Desktop\JMETER\apache-jmeter-3.3\bin
And this is my script in WebDriver Sampler:
System.setProperty("webdriver.ie.driver", "C:/IEDriverServer.exe");
WDS.sampleResult.sampleStart()
WDS.browser.get('http://www.google.com')
WDS.sampleResult.sampleEnd()
You have at least 3 ways of setting a JMeter Property:
Add the relevant line to system.property file (lives in the "bin" folder of your JMeter installation)
webdriver.ie.driver=C:/IEDriverServer.exe
JMeter restart will be required to pick the property up
Pass it to JMeter startup script via '-D command-line argument` like:
jmeter -Dwebdriver.ie.driver=C:/IEDriverServer.exe -n -t ....
If you want to run JavaScript in Java you need to provide the full package name of System class like:
java.lang.System.setProperty('webdriver.ie.driver', 'C:/IEDriverServer.exe')
References:
Configuring JMeter
Apache JMeter Properties Customization Guide
Some encoding issue. I guess you have copy pasted the code from google.
Tip:
Copy the code to some text editor and then copy paste the code to eclipse.
If you are using eclipse use this command to change the encoding/format and it will work fine.
command 1: crtl+a (to select all)
command 2: ctrl+shift+f (to change the format to uft8 encoding)
Hope this helps. thanks.

Running multiple JIRA issues as Behat tests

I am using Behat and JIRA together to run automated tests. Currently I am able to run a single JIRA issue using:
$ bin/behat jira:ISSUE_NUMBER
In order to this, I am using the JIRA extension for Behat (http://extensions.behat.org/jira-extension/)
However, I am looking for a way to run a group of tests on my JIRA account. I need this to work similar to the #tags in behat.
Any help would be greatly appreciated.
Thanks,
Girish Kini
This is currently not possible. After research, I have learnt that this feature is currently not supported by the jira extension. In the interim, try adding support for a comma separated list, eg jira:issue-1,issue-2,etc-n via the FeatureLoaderService.php.
sources: Anthon Pang via vipsoft/JiraExtension [ GitHub ]
You could create a version that included all the tickets that you wanted to run. Then in your behat.yml file specify that version using jql. Afterwhich you can run the following command.
php bin/behat http://myserver.com:8080/