Allure reports doesn't contains steps when using Intellij IDEA test runner - gradle

Using Kotlin, JUnit5, Allure and Gradle.
When I use Gradle test runner, Allure report looks totally fine, but when I switch to Idea test runner, Allure reports is being created without any steps.
I believe that problem is in aspectjweaver configuration. It is configured in Gradle Allure plugin:
allure {
version = allure_version
autoconfigure = true
aspectjweaver = true
resultsDir = rootProject.file('build/reports/allure-results')
reportDir = rootProject.file('build/allure-results')
}
I'd prefer to use Idea test runner because it makes test launch faster, but it seems to be not compatible with Gradle Allure plugin.
Is it possible to configure aspectjweaver some other way and make Idea test runner accept it?

Related

IntelliJ Gradle project, no test runner tab

I try the spock test framework with IntelliJ (2021.3.2), created the demo from https://blog.jetbrains.com/idea/2021/01/tutorial-spock-part-1-getting-started/ with the first simple test.
I don't see the test runner tab (even if I could run the tests). The Gradle configuration is set by default to run tests by using Gradle. If I switch the Gradle configuration to run tests using IntelliJ IDEA, I got the test runner tab.
How could I get the test runner tab with Gradle too?

Intellij IDEA - skip jaCoCo while running individual tests

I have gradle JaCoCo configuration as advised by the docs:
test {
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test
}
I have Intellij IDEA configuration to run tests with Gradle. Currently when I run individual tests from IDEA, it also launches jaCoCo coverage report, which takes time and I would like to avoid.
So I would like:
to keep my gradle configuration so that coverage reports run every time I run build
Do not run JaCoCo when running tests from IDEA
I have tried changing gradle tasks definition in IDEA to include -x jacocoTestReport, but it has no effect. I tried to change test run configuration, but its getting reset for every new test,
Please try to set the Run tests using to "Intellij IDEA" from Preferences/Settings | Build, Execution, Deployment | Build Tools | Gradle .
enter image description here

Unit test data success/failure/count not being passed to SonarQube

I use sonarqube for analyzing a project with mixed Java / Groovy tests. The Java tests are run via TestNG, whereas the Groovy tests are run via JUnit. When running the Gradle "sonarqube" task, I get the following in build log (with --debug option):
14:38:53.842 [DEBUG] [org.sonarqube.gradle.SonarQubeTask] Class not found in resource cache : a.b.c.SomeSpec
14:38:53.842 [WARN] [org.sonarqube.gradle.SonarQubeTask] Resource not found: a.b.c.SomeSpec
This is only logged for Groovy tests.
I use two separate tasks to run JUnit / TestNG tests, and a JacocoMerge task from the Gradle Jacoco plugin to merge the binary reports from those tests. As a result, Sonarqube displays the coverage percentage correctly, however, when displaying the list of unit tests, all JUnit (hence, Groovy in my case) tests are missing.
I read No Unit Test Success data for tests written in Groovy and tried using the latest version of the plugin, however, the issue still persists. Is there any way to get both coverage AND unit test information to be displayed properly in Sonarqube using the SonarQube Gradle plugin?
I used SonarQube version 5.6.3., sonarQube Groovy plugin version 1.4 and sonarqube-gradle-plugin version 2.2

IntelliJ runs unit tests with Maven instead of JUnit

I have some Unit tests, that when I try to run, it automatically creates Maven run/debug configuration, instead of JUnit (the integrated IDEA tab).
For some tests it does use JUnit run\debug configuration and manually - I can create both Maven and JUnit.
How do I make JUnit to be the default test runner ?
The problems is that I had maven runner plugin installed, causing all my tests to run with Maven
You can use the maven option "-Dskip=true" to suppress the maven test execution, and you can add your own test configuration to the build process. This screenshot was taken form IntelliJ 15.0.2.
Update: maven option

Selenium tests Jacoco project coverage

I am running my selenium project module which isn't part of the main project,
I run the selenium tests with Jacoco maven plugin and the surefire plugin,
The Jacoco gives a code coverage (exec file) only of the selenium project and not for the whole project...
How do i need to configure my Jacoco and Surefire in order to get an external/whole project coverage??
It is not true that you can not measure code coverage of your selenium tests.
Take a look a t JaCoCo as a tool: https://www.eclemma.org/jacoco/
It can measure the code coverage of: unit, integration, GUI tests and to combine it in one aggregated report.
You need to configure a jacoco java agent (tcpserver) in the running project to be tested & a jacococlient (jacococli.jar) to listen to the results.
Example:
java -javaagent:path/to/your/jacocoagent.jar=address=*,port=36320,destfile=jacoco-it.exec,output=tcpserver -jar target/yourApplication.jar
Run end-to-end integration tests.
Dump the results:
java -jar path/to/your/jacococli.jar dump --address localhost --port 36320 --destfile target/jacoco-it.exec
sleep 5
java -jar path/to/your/jacococli.jar report target/jacoco-it.exec --classfiles target/classes --sourcefiles src/main/java/ --html target/jacoco-report
I'm not sure if I do not understand your question correctly… But if I understand it correctly, you want to see the code coverage for Selenium Tests on the productive code?
That is simply impossible! Selenium helps you test the web application. Your code is not being tested with Selenium, but just the web pages resulting from the process of your application.

Resources