Run JUnit test in IntelliJ IDEA 14 without choosing configuration type

自闭症网瘾萝莉.ら 提交于 2019-12-03 15:01:27

问题


In IntelliJ IDEA 14 with Gradle plugin I would like to run JUnit test without being asked about configuration type. Problem occurs when I run test for the first time - there is no configuration for this run. I never run tests with Gradle in IDE so it would be acceptable to disable running test with Gradle. How to run JUnit test directly?


回答1:


You can get rid of this annoying by adding

idea.gradle.prefer.idea_test_runner=true

to idea.properties file located in the bin directory of the IntelliJ IDEA installation. Then restart IDEA and enjoy.




回答2:


Go to setting > Build, Execution, Deployment > Build Tools > Gradle > Runner and choose "Platform Test Runner" in "Run test using"




回答3:


The Gradle Test Runner configuration looks a bit different in IntelliJ 2019.2 :

To have Intellij rather than Gradle run your tests when you right-click on the test/Test Class/Test package select IntelliJ IDEA for the "Run tests using:" option.

Having IntelliJ run your test means that a Junit configuration is created to run the test.

When I upgraded IntelliJ 2019.1 to 2019.2 I found that the default setting for the Gradle runner was set to 'Gradle' which meant that my unit tests didn't run properly when I right-clicked on a test and selected 'Run' - they just terminated with no results. I had to change the "Run tests using:" option to IntelliJ IDEA



来源:https://stackoverflow.com/questions/27972479/run-junit-test-in-intellij-idea-14-without-choosing-configuration-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!