How to output karate test results to custom folders instead of target? - cucumber

We recently started using karate for API testing in our project and we are using Executable Jar File with visual studio plugin for karate. Currently We are not using any test runner classes or Junit in our framework and still able to achieve almost everything by usage of tags and karate-config.js file. We are using both cucumber-html report and surefire-report plugins and results generated at target folder on execution.
Now we are looking to customize the outputs to different folders. I assume we could use the reportDir() parameter to set the output folder path. Can someone please advice is it achievable in Executable Jar version and without Junit framework? If possible, where can I set this path in our tests? Do I need to create a test runner class for this ?

Can you please start evaluating the RC version, details here: https://github.com/intuit/karate/wiki/1.0-upgrade-guide
You should be able to set a different "output" folder using the command-line -o or --output flag.
Based on your feedback, we can improve it.

Related

How to debug through a cucumber karate project

I have inherited a Java / Maven / Cucumber project. I am fairly new to Cucumber.
Inside one of the folder I have a class like this...
import com.intuit.karate.junit4.Karate;
import org.junit.runner.RunWith;
#RunWith(Karate.class)
public class RoadsRunner {
}
Then in the same subdirectory / package I have a .feature file.
with a number of scenario's.
Feature: Check transaction
Background:
* url apiHost + '/api/v1'
* configure headers = {'X-TransactionID': '#(Math.random().toString())' }
Scenario: Get Classes
# get classes
Given path '/myUrl/classes'
And param processName = 'myProcess'
When method get
Then status 200
Question One.
I am using Eclipse. Is there a way I can debug through the test in a similar way that I would debug a Java app?
I have downloaded myself the Cucumber Eclipse plugin but can't quite figure out how to use it.
Question Two.
Without using a custom plugin to debug is there anything I can add to the scenarios to maybe print extra debug information.
thanks
The Cucumber Eclipse plugin gives you 2 things:
IDE syntax coloring / formatting support
Being able to right-click and run a Feature directly without the JUnit "runner"
Karate is Java behind the scenes so you can debug and set break-points, but it may not be as seamless as you expect. In 0.6.0 you have the option of placing a conditional break-point in Karate code that runs before / after each test step - see screen-shot.
So as you rightly called out, printing to the log might be the most effective way to work through complicated test scripts. Please refer to the print keyword - which is exactly what you are looking for.
2 more points:
the optional HTML report includes all HTTP request / response logs - which is great for troubleshooting a test.
I would love for the Karate UI (currently in alpha) to become stable sooner and be the best option for debugging, please do submit feedback and contribute if you can.
EDIT: we now have the Visual Studio Code IDE support with first-class debug support: https://github.com/intuit/karate/wiki/IDE-Support#vs-code-karate-plugin
EDIt2: If you want to debug Java code, that is possible with the new IntelliJ plugin: https://plugins.jetbrains.com/plugin/19232-karate
As per the documentation here, At this moment best way to debug Karate Steps is using Visual Studio Code for developing tests and VS Code Karate Plugin for debugging.
Visual Studio Code is Free, built on open Source and runs on all platforms including mac/linux and windows.
Please note this
The Karate UI has been retired and is not available in 0.9.5 onwards !
Use the VS Code Debug Support instead.
As per the comment by Peter Thomas, Eclipse/IntelliJ may also support debugging but I am unable to find any development there.

Cucumber Predefined steps usage

I have a project where I have written some per-defined steps and implemented.
Now I like to use the per-defined steps in another project in eclipse. Kindly let me know how could I do that?
Cucumber only knows how to read and execute your feature files because of the step definition files usually defined with in a steps directory. That is where your feature statements are captured by regular expressions and translated to Java code
The steps Cucumber will search for just live in a package, or a sub-package from the runner.
Suggestion would be to copy the step definitions from Project 2 into your steps directory in Project 1.
Also there is way to re-use steps is therefore to package the steps in a jar and add that jar as a dependency. You can use Maven for creating the jar.

how to access steps available in other cucumber project in current cucumber project

Please help me understand accessing steps available in other cucumber projects in current cucumber project.
i have tried glue option as well and i also have added other cucumber project jar file in maven dependencies but could not make it work.
Below is the feature file of project1:
Feature: To test cucumber test is running
I want to run a sample feature file.
Scenario: cucumber setup
Given sample feature file is ready1
When I run the feature file1
Then run should be successful1
Scenario: cucumber setup for cucmbertestautomation2
Given sample feature file is ready2
When I run the feature file2
Then run should be successful2
"Given sample feature file is ready2" step is available in project2.
and project1 (cucumbertestautomation1) POM have project2(cucumbertestautomation2) as dependency:
com.celcom
cucumbertestautomation2
0.0.1-SNAPSHOT
Still the step "Given sample feature file is ready2" is not recognized which is there in the project2 (cucumbertestautomation2) which is added as dependency.
The steps Cucumber will search for just live in a package, or a sub-package from the runner.
If you have steps from somewhere else, added as a dependency through a jar or similar, then these steps will be found.
They way to re-use steps is therefore to package the steps in a jar and add that jar as a dependency. You can use Maven for creating the jar.
Cucumber only knows how to read and execute your feature files because of the step definition files usually defined with in a steps directory and called something like step_definitions.rb That is where your feature statements are captured by regular expressions and translated to Ruby code.
My suggestion would be to include the step definitions from Project 2 into your steps directory in Project 1.

Orchard CMS build script - excluded module projects included in build

I'm using Orchard 1.6 and have a question regarding the build batch file.
When run, the script builds every module within the "Modules" directory, regardless of whether the module project is included in the VS solution.
Is there a setting somewhere so only module projects are built if the corresponding project is loaded in VS? (I'd like to prevent excluded/unloaded projects from being part of the build)
Thank you for any pointers.
Replace the script so that it builds based on the solution instead of the orchard.proj file.

Packaging a Groovy application

I want to package a Groovy CLI application in a form that's easy to distribute, similar to what Java does with JARs. I haven't been able to find anything that seems to be able to do this. I've found a couple of things like this that are intended for one-off scripts, but nothing that can compile an entire Groovy application made up of a lot of separate Groovy files and resource data.
I don't necessarily need to have the Groovy standalone executable be a part of it (though that would be nice), and this is not a library intended to be used by other JVM languages. All I want is a simply packaged version of my application.
EDIT:
Based on the couple of responses I got, I don't think I was being clear enough on my goal. What I'm looking for is basically a archive format that Groovy can support. The goal here is to make this easier to distribute. Right now, the best way is to ZIP it up, have the user unzip it, and then modify a batch/shell file to start it. I was hoping to find a way to make this more like an executable JAR file, where the user just has to run a single file.
I know that Groovy compiles down to JVM-compatible byte-code, but I'm not trying to get this to run as Java code. I'm doing some dynamic addition of Groovy classes at runtime based on the user's configuration and Java won't be able to handle that. As I said in the original post, having the Groovy executable is included in the archive is kind of a nice-to-have. However, I do actually need Groovy to be executable that runs, not Java.
The Gradle Cookbook shows how to make a "fat jar" from a groovy project: http://wiki.gradle.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar
This bundles up all the dependencies, including groovy. The resulting jar file can be run on the command line like:
java -jar myapp.jar
I've had a lot of success using a combination of the eclipse Fat Jar plugin and Yet Another Java Service Wrapper.
Essentially this becomes a 'Java' problem not a groovy problem. Fat Jar is painless to use. It might take you a couple of tries to get your single jar right, but once all the dependencies are flattened into a single jar you are now off an running it at the command line with
java -jar application.jar
I then wrap these jars as a service. I often develop standalone groovy based services that perform some task. I set it up as a service on Windows server using Yet Another Java Service and schedule it using various techniques to interact with Windows services.

Resources