Jacoco : JUnit test cases are mandatory? - junit4

I am planning to implement Jacoco in my project. So just wanted to know that is it mandatory that i have to write Junit test cases or i can use existing regression test cases in other tools such as selenium or soap-Ui Pro.

In another words i wanted to know whether we can get code coverage using black box test cases. And the answer is yes. To get coverage for black box test cases using jacoco, you will have to inject jacoco agent in you AUT shell/bat application start up file. Which in turn creates a jacoco.exec file containing information about coverage.Pass this file to jacoco API ReportGenerator and you can create html reports about coverage.

Related

How to integrate rest api test using soapui with selenium using junit framework

I want to integrate selenium-webdriver framework written using junit with soapui rest api test suites, is there a way to do it?
Thanks in advance
Based on your comments, here is how you need to change your tests, so that, you will be able to run both kinds of tests together from within SoapUI i.e.,rest and ui.
I am not sure, if you already happened to create a soapui project. If not, create the project, import your .wadl or swagger definition of REST API.
Then create test suite, and test cases as required.
Now the test case should be having the steps as defined:
Rest Request Step(one or multiple steps) : this contains all your rest api calls
Groovy Script : Whatever test code that you have in your junit test, needs to come here. Groovy should be able to run most of your java code. But, if you are familiar, you can add groovy code itself. So, that it will be able to do exactly the same as you run it from your eclipse IDE.
Bringing your test steps into soapui test case will also have an added advantage that you can even share the data (in the form of variables ) across rest and UI as well.
You can even execute the tests using SoapUI's commandline utility testrunner.bat/.sh of SOAPUI_HOME/bin directory.
It is also possible to define application url / credentials in the form of Project / test suite / test case level properties (as applicable to the tests) and use Property Expansion. This even helps to run the tests against different servers such as dev, qa etc.,
I understand that you wanted to junit to execute the tests, but if you wanted to purely junit, then there is no need / get benefit using SoapUI. Instead of SoapUI, you can use different library, such as groovy wslite to make rest calls in junit itself .
Hope this helps.

Using sln.DotSettings in TeamCity dotcover runner

I am using an NUnit 3 runner in a TeamCity 9.1.6 step. I've chosen "JetBrains dotCover" as the .NET Coverage tool, and now I'd like this step to use the xxx.sln.DotSettings file that we've put in source control and that we're sharing across devs in Visual Studio, rather than to duplicate settings to TeamCity Filters, Attribute Filters etc. Is this possible in TeamCity?
It is not possible from the box now. It is a great idea, could you create an issue here https://youtrack.jetbrains.com/
But there is a simple workaround:
you could parse dotSettins manually on the first step
publish configuration parameters using ##teamcity[setParameter name='ddd' value='fff'] TeamCity service message (see for details https://confluence.jetbrains.com/display/TCD9/Build+Script+Interaction+with+TeamCity)
use those configuration parameters in the appropriate fields for dotCover like %ddd%

Jacoco code coverage for remote machine

I tried to find this answer but hardly found it anywhere. I am doing the API testing, In process I need to call the rest API from my local machine. local machine contains the maven project and a framework to call respective rest API.
I need to check the code coverage of remote Rest API and form a report based on the code coverage. please help, how to do that?
Note: I found this link useful but it does not elaborate clearly on what to do?
http://eclemma.org/jacoco/trunk/doc/agent.html
you will probably do a bit of file copying around - depending on the way you run the tests.
JaCoCo runs as a java agent. So you usually add the javaagent parameter as mentioned in the docs you linked to the start script of you application server.
-javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]
so it would look like:
java -javaagent: -jar myjar.jar
Using tomcat you can add the "-javaagent" part into JAVA_OPTS or CATALINA_OPTS environment variables. Should be similar for other servers.
this will create the jacoco*.exec files. you need to copy those back to your build or CI server to show its results (for ex if you use sonar you need those files before running the sonar reporter). Its important to just include the packages you're interested in.
You can also create one jacoco.exec file per test flavour (jacoco.exec for unit tests, jacoco-it.exec for integration tests, jacoco-at.exec for application tests).
And I would not mix coverage with performance testing - just to mention that too.
There are some examples on stackoverflow for JBoss

Allure and Hapi Lab coverage reports

I am in the process of trying to figure out if we can use the Allure plugin for TeamCity to show code coverage, and completed tests in our build pipeline.
All of the tests for our web services are written in CoffeeScript using Hapijs Lab.
When we run the tests now we use 'npm test' and once the tests complete a coverage.html document is generated.
Does anyone know of a way that I can convert this coverage.html report into a format that Allure would understand? From what I have read it seems that Allure is expecting XML. Does anyone have experience in converting an existing report into XML?
When you run your lab tests you can add the flag:
lab tests.js --reporter junit
And you will get a junit style xml output.
Then you need to make sure you have the JUnit adapter installed for allure. You can find info about that here:
https://github.com/allure-framework/allure-core/wiki/JUnit

Cruise Control.NET, NUnit integration

I currently have a code base which has NUnit tests organised into suites. We currently have a build task on our CC box which runs all of the tests in one CC project.
Is there a way we can configure CC.Net to allow us to individually run the different test suites from the dashboard.
Something along the lines of a list of all the suites and a button next to each to run those tests.
The only way I can think of doing it now is to set each suite up as its own project and control them all from the top level dashboard, but we have alot of test suites and this complicates adding more.
Thanks in advance.
I'm afraid there is no other solution than creating a separate project for each test suite.
How could CCNET be aware of something like a test suite? What about different implementations of test suites?
For CCNET a project is atomic i.e., a project is the smallest available element you can run and evaluate the results for.