java 选择要运行的配置类型时,在 IntelliJ IDEA 15 中运行 Gradle 测试而不是 Junit 测试

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34332580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 22:46:33  来源:igfitidea点击:

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

javaintellij-ideagradlejunitintellij-15

提问by SamTheGoodOne

I want this feature backI 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.

我想要这个功能回来我从 14 更新到 Intellij 15.02 并想使用 Gradle 而不是 JUnit 运行我的测试,但我不再像您在此处看到的图像那样获得选项。

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.

当我运行测试时,现在发生的事情是它默认将它作为 JUnit 测试运行。

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.

我已经通过选择项目中的 gradle 文件导入了带有 gradle 的 gradle 项目。我已经删除了顶部的每个配置条目,因此在使用 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.

我目前的“修复”是为 gradle 测试手动创建一个新的配置条目。Intellij 不够智能,无法创建与 Gralde 测试相同的 Junit 测试。

I'm confused.

我糊涂了。

回答by SamTheGoodOne

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

我找到了解决方案。他们已经更改了您在新版 Intellij 15.02 中选择此选项的方式。

You have to select Gradle Test Runner.

您必须选择 Gradle Test Runner。

Please take a look: enter image description here

请看一下: 在此处输入图片说明

回答by Adolfo

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

在 IntelliJ 的现代版本(我有 Ultimate 2019.2.3)中,您需要更新以下内容: 更改gradle设置

Update from "Gradle" to "IntelliJ IDEA"

从“Gradle”更新为“IntelliJ IDEA”