Intellij IDEA - skip jaCoCo while running individual tests - gradle

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

Related

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

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?

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?

How to skip test task when running sonarqube task?

When I execute sonarqube task, by default test task runs. How can I configure Gradle to not run tests when I specifically run sonarqube.
I want to configure this build.gradle.kts.
When I run
./gradlew sonarqube -x test
then tests are not executed.
I want to achieve the same by configuring in the build.gradle.kts file.

How to visualize output of JUnit integration tests in IntelliJ when using docker-maven-plugin?

IntelliJ has a nice integration with JUnit that allows me to run some or all of my unit tests and visualize the results of each test and test class with a collapsible/expandable hierarchy that even takes into account JUnit5 nested test classes. I can click on any failed test to see the log output from running just that method. It looks like this:
I have now defined an integration test phase to my project using two popular Maven plugins:
maven-failsafe-plugin separates my JUnit tests into two phases. The test classes ending in "Test" run during the test phase, and those ending in "IT" run during the integration-test phase.
fabric8's docker-maven-plugin which I'm using to spin up a test database in the pre-integration-test phase and shut it down in the post-integration-test phase.
I can tell IntelliJ to run a Maven command (such as maven clean verify) that runs this lifecycle and tells me if the tests have passed. However, a Maven "run configuration" in IntelliJ doesn't produce the same helpful output. All I get is the success or failure status of each phase, and I can navigate to the console output for a phase, but not an individual test. The output looks like this:
So here's my question: Is there any way to configure IntelliJ (or Maven, or both) to give that hierarchical test-by-test output while keeping the Maven lifecycle I've defined, with the temporary use of a docker-container database for my integration tests?
I know that I can manually spin up the test database container, use IntelliJ's JUnit runner for my integration tests, and then manually stop the container. Can I do better?
Unfortunately there is no tool to show test-by-test output while keeping the Maven lifecycle as Maven run configuration is used in this case. Please use Junit run configuration for Class/method output in test runner tab.

Exclude testng tests while building in jenkins

I have a test which consists of both junit test and testng tests. It works fine when i run 'mvn test' from parent pom, but testng tests fail while building in jenkins. I need a way to skip testng tests from running in jenkins.
You said you use jenkins so i assume that you are using maven plugin :
Have you tried to skip test cases in your Maven run? Use the code below in maven properties section of maven plugin:
maven.test.failure.ignore=true
Or
please use below code in properties section of maven plugin to skip the test cases
skipTests=true
Hope this helps
It's better to set it up via runtime in Jenkins' job configuration:
Invoke Top Level Maven -> Advanced.
Add maven.test.skip=true
Once the tests are OK, just remove this line.
You can disable test execution in runtime as well:
mvn -Dmaven.test.skip=true

Resources