How to take Test Run ID from Jenkins using selenium and Java - java

How to take Test Run ID from Jenkins using selenium and Java.
Currently i`m using Extent Reports tool with Jenkins , Selenium and Java. Which generate reports after every test run.
But the problem is: Every test run It overwrites itself.
And i want to store test results instead of overwriting them.
Storing by date or time is a bad idea.
How i can Take Build # From Jenkins and Attach
it to
htmlReporter = new ExtentHtmlReporter("/Users/admin/"+jenkinsBuildNumber+"extent.html");
Extent report. That every test run will generate Unique Report which will be stored and i can easily track them by checking Jenkins Test Case run #.

use Jenkins environment variable ${BUILD_NUMBER}
final String jenkinsBuildNumber= System.getenv("BUILD_NUMBER");
Reporter=newExtentHtmlReporter("/Users/admin/"+jenkinsBuildNumber+"extent.html");

You can publish the reports generated by the Extent Reports tool in Jenkins.
Use HTML Publisher Plugin in Post Build Actions.
By default, only the most recent HTML report will be saved, but if you'd like to be able to view HTML reports for each past build, select "Keep past HTML reports."

Related

Invalid Report generation using Xl.generateReport in Selenium TestNG

I have created a selenium webdriver project and I am using TestNg, Maven.
I want to generate report in excel format here. After searching online and looking at some videos I am using Xl.generateReport for excel report generation. I am looking at below video and have done the steps as shown in this video:
https://www.youtube.com/watch?v=1VVi185e6DI
So now I have my testng.xml file that has 2 test suites and total 5 testcases. After I run this testng.xml file, the console shows that all 5 testcases have been passed.
But when I see the report that is generated, it does not execute both the suites. It executes only one suite from testng file and skips one suite.
Also, the testcase pass/fail that is shown in excel report is wrong. It shows some testcase fail and some passed but the console in Eclipse shows all testcases are passed.
also the date of execution, the exceptions shown in excel report, all is wrong.
Thank you in advance.
I just had to update the Maven project and refresh the Reports folder to see valid test results.
It worked for me.
Thanks.

Is there a plugin or tool which I can use to generate coverage from running application without testcases?

I have a Java based web application which have few ReST endpoints exposed. I want to check the code coverage in running VM. Is there any tool or plugin I can use for this purpose?
I tried looking into jacoco but It looks like it provides code coverage only if you have configured unit/integration tests.
Sometimes, it becomes very difficult to write testcases for all possible scenarios. So, is there a way I can get code coverage without test cases?
Thanks a ton in advance. :)
After doing more search on internet, I have found a very good link which fulfill my requirements:
https://automationrhapsody.com/code-coverage-of-manual-or-automated-tests-with-jacoco/
In short, follow below steps to generate code coverage report without testcases:
Install Jacoco Eclipse plugin: EclEmma Java Code Coverage
Download jacocoagent.jar and put it some location on your computer e.g.
C:\JoCoCo\jacocoagent.jar
Run your application with this VM arguments: -
javaagent:C:\JaCoCo\jacocoagent.jar=output=tcpserver
Import coverage reports:File -> Import -> Coverage Session -> select Agent
address radio button but leave defaults -> enter some name and select code
under test.

generate the report in selenium webdriver

how can I generate the report after executing test cases in the selenium web driver. I am trying Test NG for generating report but I have to write different code to get the report?
If you use Maven with Surefire plugin (which I strongly recommend), report is always located in target/surefire-reports/index.html. If that is not enough for your than you can use ReportNG library which is supposed to have more convenient reports in HTML format.

List jUnit Tests That Were Run

Is there a way to get a list of the jUnit tests that were run for the purpose of including that list in a report?
Rather than copying the 80 unit tests I ran, I was hoping to output it as html or a csv that I could then turn into a figure for my report.
Extra points if the pass/fail status of each test were included.
It depends how you run them, but if you're using maven, then the surefire plugin produces a report for you.
If you're using ant, see How do I use Ant to create HTML test reports?

Selenium - convert html to junit programmatically

Is it possible to programmatically, in java, convert Selenium HTML file to JUnit test source code?
I need my own program which gets only resources of these html files, converts them to java code and automatically runs the JUnit test. Is there any way to do that?
In Selenium IDE, it is possible to export test cases to JUnit, I know that, but I don't want to use IDE, I need to do this programmatically as I said once before.
I believe that someone needed this before and someone can help me...
How about http://code.google.com/p/selenium4j/ ??
How does Selenium4j work?
In short Selenium4j translates the HTML tests to Java JUnti tests.
UPDATE
Maven port of this project available through https://github.com/willwarren/selenium-maven-plugin:
<dependency>
<groupId>com.gbi.maven</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0.2</version>
<scope>test</scope>
</dependency>
Also it mirrored at warious MVN repos:
http://mojo.codehaus.org/selenium-maven-plugin/
There exists a Firefox plugin for the Selenium IDE called Test Suite Batch Converter which can convert batches of HTML files to any export format the IDE supports.
I took the selenium4j project and turned it into a maven plugin for those who want to take the html test cases and automatically have them run with your maven test phase. You can also separate the tests out using a profile override with surefire.
Readme is here: https://github.com/willwarren/selenium-maven-plugin
The short version of the readme:
Converts this folder structure:
./src/test/selenium
|-signin
|-TestLoginGoodPasswordSmoke.html
|-TestLoginBadPasswordSmoke.html
|-selenium4j.properties
Into
./src/test/java
|-signin
|-firefox
|-TestLoginGoodPasswordSmoke.java
|-TestLoginBadPasswordSmoke.java
This is only tested on windows with Firefox and Chrome.
I couldn't get the IE version to pass a test, but I'm new to selenium so hopefully, if you're a selenium guru, you can get past this.
Look at the selenese4J-maven-plugin. Similar to selenium4j (https://github.com/RaphC/selenese4j-maven-plugin).
Provides many features : Selenium 1/2 (WebDriver) conversion Test Suite generation Internationalisation of your html file Possibility to use snippet into your html file for specific test (e.g : computing working day, write custom generation of values, handle dynamic values ...) Use of tokenized properties

Categories

Resources