Customize the directory of Karate HTML reports - karate

I am looking into organizing HTML reports into directories other than the default target/surefire-reports.
I have read in the docs that there is an existing reportDir() method for Runner. Can I utilize this method for JUnit 5 tests? If not, are there any other ways?
I came across a similar post but I am not using executable jar version so the accepted answer would not be applicable.
Any help would be appreciated.

Please start trying the 1.0 RC version: https://github.com/intuit/karate/wiki/1.0-upgrade-guide - there are changes to the Runner API and how you can control the report output dir.
And there is no reason to make this customizable for JUnit based tests, that option is only for developer convenience: https://stackoverflow.com/a/65578167/143475
Also note that in the 1.0 version, if the reports dir already exists, it will be renamed - and maybe that behavior is sufficient.
Any other change may require you to contribute code.
Also see: https://stackoverflow.com/a/69490494/143475

Related

How to change report directory in karate? [duplicate]

I am looking into organizing HTML reports into directories other than the default target/surefire-reports.
I have read in the docs that there is an existing reportDir() method for Runner. Can I utilize this method for JUnit 5 tests? If not, are there any other ways?
I came across a similar post but I am not using executable jar version so the accepted answer would not be applicable.
Any help would be appreciated.
Please start trying the 1.0 RC version: https://github.com/intuit/karate/wiki/1.0-upgrade-guide - there are changes to the Runner API and how you can control the report output dir.
And there is no reason to make this customizable for JUnit based tests, that option is only for developer convenience: https://stackoverflow.com/a/65578167/143475
Also note that in the 1.0 version, if the reports dir already exists, it will be renamed - and maybe that behavior is sufficient.
Any other change may require you to contribute code.
Also see: https://stackoverflow.com/a/69490494/143475

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

Selenium Maven Project

I am new to automated testing. I am trying to set up a Maven project for my Selenium test automation work. I put all the packages pertaining to envVariables, library, settings, resultLog, errScreenshots etc under src/test/java.
I have a couple of questions here
i)I showed this framework to my developer and he asked me to move some of the packages under src/test/resources. I am not sure whether this needs to be done or whatever I have configured is correct. If I need to move the packages to resources folder, what packages should I move? Can somebody please advise me on how to configure this?
ii) what should the src/main/java folder contain? I thought it will contain the src code of my application and test folder would contain unit tests and selenium tests. But my developer says the test folder will contain only unit test that test the classes in the src/main/java. It should not contain my selenium tests. Can somebody please explain this to me?
Regards
vasu
I am not sure about the structure of your automation project. I prefer the following hierarchy in MAVEN projects
src
|-----main
| |-----java
| |-----Pages (contains application code arranged as one Class per Page)
| |-----Steps (calls the page objects and methods called in Pages)
|-----test
|------java
| |-----Test (Opens browser and calls steps to perform test - TestNG)
|------resources
|-----InputSheets
|-----Environment Variables
The results are saved in C or D drive and are time stamped to avoid getting overwritten.
The automation helper library is created as a separate Maven project and is added as a dependency to the test project. In this way the helper library is independent from the test project and can be used across all projects if need arises.
All this being said, much of the structure is a matter of choice and varies according to your project requirements.
"src/main/" is for production code or test automation framework, not for test cases. "src/test/" is for testing stuff, including selenium tests. "java" folders are for classes, "resource" folders are for configuration and test data.
I suggest creating a separate maven module for your testing stuff: test framework and test cases.
Please refer maven directory layout page for more information.
UPDATE: I have created sample maven project to show how run selenium test with selenide.

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 to add the target jar as a test resource of the same project?

I'm developing a Solr plugin and using the Solr test-framework I place a test SOLR_HOME dir under test/resources with /conf/ and /lib . Now the framework inistantiates a SolrCore and loads my plugin from /lib. Not an issue to output the jar of the plugin to /lib, but the issue is that the plugin is not yet available since it still needs to past the test (chicken and the egg).
How do you recommend solving this? I see those options:
Create another project for the tests with a dependency on the plugin, and in it run the tests. Simple enough, but how do I ensure that everytime the plugin is built also the tests of this other project is built? The point of the automated tests at every build is to having a new plugin jar which breaks the tests.
In dp4j pom.xml I build the project on 2 phases, in the 1st I <include> only the annotation processors while in the other I compile the tests which rely on the annotation processors compiled in the eariler phase.
I'm in favor of 2 since copy-pasting the configuration doesn't seem a bad option, and makes it seem less complicated than it probably is. I don't remember if I had asked about it here - what do you recommend? Any other case studies /working code to look at?
there's a 3rd. most probably best solution ~ do nothing!
I was under the impression that the Solr Testframework need to load my plugin from /lib but apparently it doesn't need to, it can load it from test-classes, all on its own!