2016-06-14 8 views
1

私は戦争プロジェクトがあり、私は単体テストを実行しようとしています。残念ながら、私はこのClassNotFoundExceptionを 'compileOnly'依存関係のクラスに対して受け取りました。私はこのクラスをテストクラスパスに追加しようと何時間も成功しなかった。どんな助けもありがとうございます。gradle test class notfoundexception for compileOnly dependency

Gradleのファイルをビルドするには以下の通りです:

buildscript { 
    repositories { 
     mavenCentral() 
     maven { 
      name = 'Sonatype Nexus Snapshots' 
      url = 'https://oss.sonatype.org/content/repositories/snapshots/' 
     } 
    } 
    dependencies { 
     classpath 'net.wasdev.wlp.gradle.plugins:liberty-gradle-plugin:1.1-SNAPSHOT' 
    } 
} 

plugins { 
    id 'eclipse-wtp' 
    id 'war' 
    id 'org.unbroken-dome.test-sets' version '1.2.0' 
} 

apply plugin: 'liberty' 

compileJava.options.fork = true 
compileJava.options.forkOptions.executable = project.property('JDKPath') 


// In this section you declare where to find the dependencies of your project 
repositories { 
    // Use 'jcenter' for resolving your dependencies. 
    // You can declare any Maven/Ivy/file repository here. 
    jcenter() 

    flatDir { 
     dirs 'WebContent/WEB-INF/lib' 
    } 
} 

configurations { 
    testCompile.extendsFrom compileOnly 
    testRuntime.extendsFrom compileOnly 
} 

testSets { 
    integrationTest 
    endToEndTest 
} 


dependencies { 

    // Libraries that will be provided by WebSphere. 
    compileOnly group: 'javax.servlet', name: 'javax.servlet-api', version: '3.0.1' 
    compileOnly group: 'com.ibm.websphere.appserver.api', name: 'com.ibm.websphere.appserver.api.json', version: '1.0.12' 



    testCompile group: 'junit', name: 'junit', version: '4.12' 
    testCompile group: 'com.jayway.restassured', name: 'rest-assured', version: '2.9.0' 
} 


sourceSets { 
    test { 
     compileClasspath += [configurations.compileOnly] 
     runtimeClasspath += [configurations.compileOnly] 
    } 
} 

答えて

0

私は深い例外スタックに掘る必要があった、と私はやったとき、私は依存性が欠けていたことがわかりました。

関連する問題