Run Gradle test and not Junit test in IntelliJ IDEA 15 when choosing configuration type to run with
Asked Answered
P

2

40

I want this feature back I updated to Intellij 15.02 from 14 and wanted to run my tests using Gradle not JUnit, but I'm not getting the options anymore like the image you see here.

I want to be able to choose configuration type.

The thing that is happening now when I run a test is that it runs it as a JUnit test by default.

I have imported the gradle project with gradle by selecting the gradle file in the project. I have deleted each configuration entry at the top so everything is clean and empty when running a new test with Spock.

My current "fix" is to manually create a new config entry for the gradle test. Intellij is not intelligent enough to create that same Junit test as a Gralde test.

I'm confused.

Pigeontoed answered 17/12, 2015 at 10:43 Comment(0)
P
56

I found the solution. They have changed the way you select this option in the new version of intellij 15.02.

You have to select Gradle Test Runner.

Please take a look: enter image description here

Pigeontoed answered 17/12, 2015 at 11:35 Comment(9)
Do you have this working with 2016? I don't have the drop-down option and changing this setting doesn't seem to have an impact.Stuff
2016.1.3 also works. If not, refreshing Gradle helps. However. Android Studio 2.1 won't work and it's of no use to change the runner.Counterproposal
I can confirm that IntelliJ IDEA 2016.1.3 ignores this setting if you have a mixed Gradle project having Java & Android subprojects.Acie
Thank you so much for this.Megdal
Not working in 2018.1.4. Opened a bug on their ticketing system: youtrack.jetbrains.net/issue/IDEA-191291Transsonic
Actually, this is a problem only with Scalatest (JUnit runner works fine and delegates the work to Gradle).Transsonic
It works for me for a java test in 2018.1. When running with JUnit runner, it fails. I adjusted to "Let me choose per test", and press ALT+SHIFT+F10 and selected the Gradle configuration for one specific test, and then the test passed.Shatter
The Gradle runner configuration setup is a bit different in IntelliJ 2019.2 - see https://mcmap.net/q/408227/-run-junit-test-in-intellij-idea-14-without-choosing-configuration-typeInstrumental
This worked for me! Now the location in settings is Build, Execution, Deployment >> Build Tools >> Gradle. I set the field Build and run using: to Gradle.Tonguelashing
P
23

In modern versions of IntelliJ (I have Ultimate 2019.2.3) here's what you need to update: change gradle settings

Update from "Gradle" to "IntelliJ IDEA"

Poplin answered 2/10, 2019 at 18:8 Comment(2)
I wonder why they use gradle by default. It is slower and provides less options in the configuration dialog..Sahara
works flawlessly faster @PoplinFagin

© 2022 - 2024 — McMap. All rights reserved.