带有gradle和Jacoco插件的Spring Boot

时间:2016-08-09 14:26:44

标签: java spring gradle jacoco

当我将Jacoco插件添加到我的项目apply plugin: "jacoco"中时。然后使用数据库集成的单元测试不起作用。

Spring数据源配置(application.yml):

spring:
  profiles: test
  datasource:
    driver-class-name: org.postgresql.Driver
    password: postgres
    testWhileIdle: true
    url: jdbc:postgresql://localhost:5432/atol-test
    username: postgres
    validationQuery: SELECT 1

我使用了1.3.6.RELEASE版本的spring boot,我按照以下方式配置了Jacoco:

jacoco {
    toolVersion = "0.7.6.201602180812"
    reportsDir = file("$buildDir/customJacocoReportDir")
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled false
        html.destination "${buildDir}/jacocoHtml"
    }
}

当我想开始单元测试时,stacktrace给了我:

org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "test" are currently active).
at org.springframework.boot.autoconfigure.jdbc.DataSourceProperties.getDriverClassName(DataSourceProperties.java:180)
at org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$NonEmbeddedConfiguration.dataSource(DataSourceAutoConfiguration.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)

任何人都知道最新情况(正如我所提到的 - 没有Jacoco一切正常)?

0 个答案:

没有答案