Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip tests in IntelliJ using Gradle

Tags:

Does anyone know how I can skip JUnit tests in IntelliJ when doing a Gradle build like the following command line version? I have searched extensively for a solution but can't find one. I am in the process of converting an existing project to Gradle and need to support many developers that are not familiar with Gradle, some UX, some front end, and some Java. There are many broken Junit tests in the myriad modules and long-term we will fix them. Short term I need all other developers to use the tools they are familiar with to be able to do their job easily.

./gradlew build -x test

The Gradle-Android Compiler settings allow for command-line options but not non-android projects as shown in the IntelliJ settings dialog shown below.

enter image description here

like image 375
Gremash Avatar asked Nov 17 '14 23:11

Gremash


People also ask

How do I skip test cases in Gradle?

To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build.

How do I skip test cases in IntelliJ?

to toggle the Skip tests mode. On the Runner page, select Skip tests and click OK. IntelliJ IDEA de-activates the test goal under the Lifecycle node. The appropriate message notifying that tests are skipped is displayed in the Run tool window when you execute other goals.

Does Gradle build run tests?

By default, Gradle will run all tests that it detects, which it does by inspecting the compiled test classes. This detection uses different criteria depending on the test framework used. For JUnit, Gradle scans for both JUnit 3 and 4 test classes.


2 Answers

You should be able to run a standard clean build from intellij if it's a gradle project (aka gradle integration in intellij). Then edit the configuration and add at the script parameters : -x test which will run the clean build (or any other task) without running tests.

IntelliJ Screenshot

like image 142
Cristi Iaroi Avatar answered Sep 22 '22 06:09

Cristi Iaroi


I am using Intellij IDEA 2019.3 (Community Edition).
You can skip test using following settings.

enter image description here

You can get to this via Gradle panel located at right top corner.
Select task -> Run Configuration -> Right click -> Edit Run Configuration..

enter image description here

like image 26
Muhammad Tariq Avatar answered Sep 21 '22 06:09

Muhammad Tariq