Java Gradle和TestNG的Intellij设置

Java Gradle和TestNG的Intellij设置,java,gradle,testng,intellij-14,Java,Gradle,Testng,Intellij 14,我开始在Intellij中使用selenium和TestNG(Java基础语言)创建一组测试。我能够在IntelliJ中编译和运行,但是当我添加一个gradle文件(如下所示)时,我得到了一些编译路径错误 格拉德尔: apply plugin: 'java' dependencies { testCompile(group: 'org.uncommons', name: 'reportng', version: '1.1.4') { exclude(modu

我开始在Intellij中使用selenium和TestNG(Java基础语言)创建一组测试。我能够在IntelliJ中编译和运行,但是当我添加一个gradle文件(如下所示)时,我得到了一些编译路径错误

格拉德尔:

    apply plugin: 'java'


dependencies {

    testCompile(group: 'org.uncommons', name: 'reportng', version: '1.1.4') {
        exclude(module: 'testng')
    }

    testCompile group: 'com.google.inject', name: 'guice', version: '3.0'
    compile group: 'xml-apis', name: 'xml-apis', version:'1.4.01'

}

configurations.all {
    resolutionStrategy {
        force 'xml-apis:xml-apis:1.4.01'
    }
}

task testfeature1(type: Test) {
    ignoreFailures = true
    useTestNG() {
        suites 'Resources/Dashboards/feature1_testng.xml'
        useDefaultListeners = false
        listeners << 'org.uncommons.reportng.HTMLReporter'
        listeners << 'org.uncommons.reportng.JUnitXMLReporter'
    }
}

我猜Intellij会把东西编译到out文件夹,正如我现在看到的,但没有build文件夹。我如何改变这一点,使gradle和Intellij以同样的方式工作?

让我举出另一个我正在从事的示例项目:

在my build.gradle的顶部,它的配置如下:

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
然后使用以下命令设置项目:

gradle clean idea
如果您将测试输出发送到/out,那么您可能是以TestNG的形式运行测试,而不是从Gradle执行器运行测试。如果您做得正确,Gradle将生成一个
/build
文件夹,您可以通过以下方式控制生成测试报告的位置:

test {
    reports.html.destination = file("$buildDir/reports/gradle")
    ....

作为“纯TestNG”运行测试而不是使用Gradle executor的一个优点是IntelliJ IDEA将向您显示有关单个测试成功的更多信息。当与Gradle一起运行时,IntelliJ IDEA不够聪明,无法向您显示这些信息,因此您需要依赖您的测试报告。

您的构建中是否有IntelliJ插件。Gradle?不,我不知道,他还抱怨您没有测试源,您的测试类在哪里?
test {
    reports.html.destination = file("$buildDir/reports/gradle")
    ....