How to configure and execute multiple Tags for junit in Intellij in Run/Debug Configuration - intellij-idea

I have some junit5 tests in my project, I have used the #Tag annotations for some of the classes. I am successfully able to run those classes from Intellij via configuring the Run/Debug like below. This looks good when I use single type of tag eg. suite-three
Image-1
The problem I am facing is, Now I want to run classes with two different tags at the same time, since I am executing the some tests Parallelly. Inorder to achieve this I have created an intermediate Bootstrap kind of class where I am using #SelectClasses annotations class to pass this 2 Test classes which I wish to execute like this
Image-2
. So here when I configure the Tags from Intellij like below screenshot
Image-3
Notice I am sending two different tags, but Intellij doesnt executes the Test class and it keeps on giving me this message "No Tests Found".
Any help would be mighty helpful to me.

We can use | pipes for running multiple classes together viz. tag-1 | tag-2 this will run all the classes which are tagged with tag-1 OR tag-2. I am running this classes parallelly with JUnit5's new method with usage of junit.jupiter.execution.parallel.enabled = true

Related

How to integrate Galen reports in Jenkins

I've started to use Galen framework to test the layout of my website pages and I also have my other test, written in Selenium, integrated into Jenkins.
I'm using Java+JUnit+Maven and I would like to know if anyone has managed to integrate the Galen reporting into Jenkins and how.
Because for the moment I am using something like:
assertThat(layoutReport.errors(), is(0));
which tells me if there were errors in the tests but not where.
Thanks!
P.S. If someone with reputation could make the tag galen-framework so that we can group these type of questions, it would be great :D
In your case you could use Galen for generating HTML reports as it normally does when you run tests with it. Though you will have to manage the creation of GalenTestInfo objects.
Here is how the HTML report generation works. Imagine you have somewhere obtainAllTests method defined which returns a list of all executed tests.
List<GalenTestInfo> tests = obtainAllTests();
new HtmlReportBuilder().build(tests, "target/galen-html-reports");
Somewhere in your code you could create a GalenTestInfo and add it to some collection:
GalenTestInfo testInfo = GalenTestInfo.fromString("Here goes the name of your test");
Once you have done the layout checking and obtained LayoutReport object you could add this report to the report of the test. Here is how you can do it:
LayoutReport layoutReport = Galen.checkLayout(driver,
specPath, includedTags, null,
new Properties(), null);
testInfo.getReport().layout(layoutReport, "A title for your layout check");
You can find more insights in this project https://github.com/galenframework/galen-sample-java-tests. It has a basic setup for Galen tests in Java + TestNG + Maven. The reports in it are collected in a singleton GalenReportsContainer. There is also a reporter implemented in GalenReportingListener which takes all those tests from GalenReportsContainer and generates HTML reports.
You can see a full example for Java (TestNG and JUnit) and JavaScript here:
https://github.com/hypery2k/galen_samples.
I use the HTML Plugin together with Jenkins, see example here

Sonarqube API single class test coverage

I am trying to retrieve the unit test code coverage for individual classes through the SonarQube API (Sonar version 4.1.2). Everything is working fine, and I can see the metrics okay when I go directly to the sonar dashboard and go to the coverage tab for a class:
93.9% by unit tests Line coverage: 97.9% (285/291) Branch coverage: 85.0% (113/133)
Can anyone tell me the correct call to retrieve this same/similar information through the sonar API interface please? I've already had a look at the documentation at http://docs.sonarqube.org/display/SONAR/Metric+definitions and can get test coverage metrics back at project level but I can't see how to construct a query for individual classes.
I think this is what you are after
[hostname]/api/resources?resource=[com.test]:[module-name]:[fully qualified class]&metrics=coverage,branch_coverage
I have added an example below.
http://sonar-server/api/resources?resource=com.test:module:com.test.service.impl.CheckServiceImpl&metrics=coverage,branch_coverage
I looked at the page you shared and used this also :
http://docs.codehaus.org/pages/viewpage.action?pageId=229743280
api/measures/component_tree is your friend
result = session.get(
SONAR_BASE + "api/measures/component_tree",
params={"baseComponentId": COMPONENT, "metricKeys": "coverage" )
)
gets you coverage down to the file level. You should be able to only get the files with the "leaves" strategy.

Reuse Geb Pages for multiple domains

I'd like to test the search functionality of 30 websites that are generated by the same CMS under different domains with different Lucene-indexes. For this purpose I'd like to write a single Page Object which I'd like to be fed by the configuration with those 30 different baseUrls.
I'd be running those tests in the same environment so I'm not sure how to approach this issue. Is there anything I've been missing so far? Looking forward to a push in the right direction and thanks in advance.
You can always override the base url in your test using using browser.config.baseUrl = 'http://example.com'. It will be reverted to the value configured in GebConfig.groovy for the next test.
The question is how many tests do you wish to run this way? If it's just one test then you can get away by using Spock's support for parametrised tests with where: block and this approach. If it's more than one test then you will probably be looking at custom test runners or running your tests multiple times using your build system with different geb environment settings.

How to access views defined with a specific [plone.]browserlayer in test cases

I'm new to testing and I'm trying to create a test for my Plone product for the first time.
I'm on Plone 3.3.
The basic test suite works, I can execute it without errors.
I followed this documentation : http://plone.org/documentation/kb/testing
...except that I'm writing my tests in Python classes instead of doctests.
My problem is that I cannot seem to access the views defined in my app (I get ComponentLookupError).
The problem seems to be with the "browserlayer" defined by my applications.
When I remove the layer="..." attribute from my configure.zcml, the test can access the views without problem. However, if I add it back, it doesn't work.
I guess that's because de browserlayer interface doesn't get applied to the request.
The only reference to this problem I found is in the tests for googlesitemap : http://dev.plone.org/collective/browser/googlesitemap/googlesitemap.common/trunk/googlesitemap/common/tests?rev=
The author seems to have made a custom ZCML file for the test, in which the layer="..." attribute has been removed. (which would work but it seems very bad having to maintain a separate zcml file for the tests)
In my test, I have included the following (taken from the googlesitemap tests), which passes :
from jambette.site.interfaces import IJambetteLayer # this is my browserlayer
from plone.browserlayer.utils import registered_layers
self.assertTrue(IJambetteLayer in registered_layers())
So I think my skin and browserlayer are registered correctly.
Is there anything I need to do so that the browserlayer will be applied to the request?
Browser layer interfaces are simply 'painted' onto the request with directlyProvides. Simply do so in your test setup before you look up the view:
from zope import interface
from jambette.site.interfaces import IJambetteLayer
...
directlyProvides(request, IJambetteLayer)

Issue with the karate parallel runner

I wanted to see if anyone else might have observed the same issue. I looked in the project for any open/closed issues that might be like this but did not notice any.
I noticed that when I use the Karate Parallel runner (which we have been using for a while now), that every GET, POST, DELETE request gets called 2x, observed in the karate logs which came in the console.
When I do not use the Karate Parallel runner only a single request is made.
I noticed this when performing a POST to create a data source in our application. When I went to the applications UI to verify the new data source was created, I saw 2 of them. This leads me down the path to research further what might be happening.
Using Karate v0.9.5 with Junit 5
minimalistic Example -
https://drive.google.com/file/d/1UWnNtxGO7gr-_Z80MLJbFkaAmuaVGlAD/view?usp=sharing
Steps To Run The Code -
Extract ZIP
cd GenericModel
mvn clean test -Dtest=UsersRunner
Check the console logs API scenario get executed 2X
Note - It works fine for me for karate V0.9.4 with Junit 5
You mixed up parallel runner and JUnit runner and ended up having both in one test method. Please read the documentation: https://github.com/intuit/karate#junit-5-parallel-execution
Note that you use the normal #Test annotation not the #Karate.Test one.