2014-12-15 2 views
7

Gradle (2.1) 및 IntelliJ (14.0.2)가 제대로 재생되도록하려고합니다. 특히 IntelliJ에 통합 테스트 용 소스 세트가 들어있는 샘플 Gradle 프로젝트를 가져 왔습니다.IntelliJ 14로 가져온 Gradle의 사용자 정의 소스

프로젝트는 명령 줄에서 Gradle을 사용하여 문제가 없으며 통합 테스트를 성공적으로 실행할 수 있습니다. IntelliJ 내부에서 실행할 때 두 가지 문제점이 있습니다.

1) 해결할 수없는 타사 라이브러리 (commons-collections)에 대한 통합 테스트의 종속성으로 인해 IntelliJ 내부 컴파일이 실패합니다.

2) 위의 종속성을 제거하고 컴파일하면 IntelliJ 내부에서 통합 테스트를 실행할 수 없습니다.

src 
    integration-test 
    java 
    resources 
    main 
    java 
    resources 
    test 
    java 
    resources 
build.gradle 

을 그리고 build.gradle :이 일이 될 수 있도록하는 방법에 대한

apply plugin: 'java' 

repositories { 
    mavenCentral() 
} 

sourceSets { 
    integrationTest { 
     java.srcDir file('src/integration-test/java') 
     resources.srcDir file('src/integration-test/resources') 
    } 
} 

dependencies { 
    testCompile 'junit:junit:4.11' 
    integrationTestCompile 'commons-collections:commons-collections:3.2' 
    integrationTestCompile sourceSets.main.output 
    integrationTestCompile configurations.testCompile 
    integrationTestCompile sourceSets.test.output 
    integrationTestRuntime configurations.testRuntime 
} 

task integrationTest(type: Test, dependsOn: jar) { 
    testClassesDir = sourceSets.integrationTest.output.classesDir 
    classpath = sourceSets.integrationTest.runtimeClasspath 
    systemProperties['jar.path'] = jar.archivePath 
} 

check.dependsOn integrationTest 

어떤 아이디어

No tests found for given includes: [org.gradle.PersonIntegrationTest.canConstructAPersonWithAName]

파일 구조는 다음과 같습니다 : 나는 다음과 같은 오류 메시지가 매우 감사.

전체 Gradle을 샘플 프로젝트 샘플/자바/withIntegrationTests 테스트 종속성과 같은 프로젝트로 integrationTest 구성에서 항목을 매핑 IDEA 말할 필요

답변

7

아래 Gradle을 배포에서 사용할 수 있습니다. 소스 루트 디렉토리도 추가해야하는지 확신 할 수 없습니다. 중요한 부분은 다음과 같습니다

idea { 
    module { 
    //and some extra test source dirs 
    testSourceDirs += file('some-extra-test-dir') 
    generatedSourceDirs += file('some-extra-source-folder') 
    scopes.TEST.plus += [ configurations.integrationTest ] 
    } 
} 

더는 다니엘의 의견을 반영하기 위해 http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html


편집에 설명되어 있습니다 : generatedSourceDirs은 Gradle을 2.2이다. 테스트 작업을 설정하려면

task integTest(type: Test) { 
    description = 'Runs the integration tests.' 
    group = 'verification' 
    testClassesDir = sourceSets.integTest.output.classesDir 
    classpath = sourceSets.integTest.runtimeClasspath 
    reports.junitXml.destination = file("${project.testResultsDir}/$name") 
    reports.html.destination = file("${project.reporting.baseDir}/$name") 
    shouldRunAfter test 
} 
check.dependsOn integTest 
+0

과 같은 작업을 사용합니다. 감사하지만 작동하지 않습니다. 다음과 같은 오류가 발생합니다 : org.gradle.plugins.ide.idea.model.IdeaModule_Decorated에서 'generatedSourceDirs'속성을 찾을 수 없습니다. 또한이 작업을 수행하려면 integrationTest 구성을 추가해야합니다. – Daniel

+0

이전 주석의 마지막 문장은 물음표로 끝나야합니다. 즉,이 작업을 수행하려면 'integrationTest'구성을 추가해야합니까? – Daniel

관련 문제