Question on Jenkins Publish JUnit Test Result - selenium

I am using jenkins pipeline, does junit command once executed during build, stores the test results even after deleting the junit reports directory? If yes, where does Jenkins reads the deleted junit reports?

Jenkins does archive the JUnit test reports. So after your pipeline finishes (e.g. on an ephemeral agent), you'll still be able to access those reports. The same is true if you remove the report folder after you captured them with the plugin.
You can tell the JUnit plugin where to find your .xml Surefire/Failsafe reports. In a declarative pipeline, this can look like the following:
post {
always {
junit '**/target/surefire-reports/*.xml'
}
}
The source code of this plugin is available on GitHub, so you can take a look at how it's achieved under the hood.

Related

Exploring options to deliver Selenium test to non-tech business team who wish to run the test on their own

Our non-technical business team need to run only 1 automation test script which will be fetching data from several hundreds rows of Excel file. I've created automation that script using a Maven project (with POM framework and Extent Report), using Selenium WebDriver, Java, TestNG, and Eclipse but not sure how to deliver the test/script to the business team. Would appreciate if you guys can suggest a few options to deliver this script to the business team so that they can change few parameters in Excel file and run the script on their own. I'm getting Extent report at the end of the test, would be best if they can get the Extent report as well.
Note: Since they are non-technical, it is preferable to avoid installing and configuring Java, Eclipse, etc tools on their machine but that's not mandatory so I'm open to check several options.
I would like to suggest few options here :
Jenkins - Install it on Any server and share login and url with them. They can execute build and no technical knowledge required.
Executable JAR - Export your project as executable JAR and deliver that JAR file. All they have to do it , Double click on JAR file OR execute via batch file and it should run that script and get done the job. Make sure all data related file should be there with JAR. i.e excel file
Note : They always need JAVA in the machine regardless of what they prefer from above to use.
Usually i used to give as batch file script, if you have jenkins, integrate your bat file in it. other wise share the batch file as it is.
Create a package JAR,
Create .bat file to execute the JAR.

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"

XSLT Reports in Selenium

How to create XSLT reports in Selenium project bases on Java and Ant.
I have already added that to my project but the result is not as per my expectation. All Testcases are passing but some are showing failed in reports
XSLT reports can be generated based on the results of your TestNG.XML file. if you are using TestNG as unit testing framework make sure to place -output directory of the TestNG should be available in home directory.
Read this (http://learn-automation.com/generate-xslt-report-in-selenium/) post you will get better Idea.

Integrate non-standard tests into TeamCity

I am trying to automate running some tests (in my own test infrastructure) with TeamCity.
We are not using java or ant but I can generate junit test results from a perl script:
run_tests.pl
Which generates junit result files (junit1.xml, junit2.xml etc.).
I have integrated this into Jenkins before by running it as a command line and giving it the path to the junit files.
In TeamCity it appears that due to the closer integration with ant and junit I need to run run_tests.pl from a ant junit task.
So how can I run a command from ant to do this? Or is there an easier way to achieve what I want (junit or other test results reported in teamcity)?
Okay, found a good way to do this. The key thing you need is XML Report processing so you don't need ant or junit tasks http://confluence.jetbrains.net/display/TCD7/XML+Report+Processing.
Summary:
Create your junit1.xml files using a command line build step
Add a build feature to your build configurations of type XML report
processing
Set report type to be ANT JUnit
Add a monitoring rule of +:junit*.xml