text 弹簧靴的Gradle模板。展示如何使用集成测试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了text 弹簧靴的Gradle模板。展示如何使用集成测试相关的知识,希望对你有一定的参考价值。

buildscript {
	ext {
		springBootVersion = '2.1.0.RELEASE'
    springDataVersion = '2.1.2.RELEASE'
	}
	repositories {
		mavenCentral()
    jcenter()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    classpath 'org.ajoberstar:gradle-git:1.7.2'
    classpath 'org.owasp:dependency-check-gradle:3.+'
    classpath 'com.github.ben-manes:gradle-versions-plugin:0.20.0'
    classpath('org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.2.0')
	}
}

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'checkstyle'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'org.unbroken-dome.test-sets'

group = ‘my.group’
sourceCompatibility = 1.8
targetCompatibility = 1.8

mainClassName = ‘my.group.Application'
applicationName = ‘nice-app-name’

bootJar {
  baseName = 'nice-app-name'
}

repositories {
	mavenCentral()
	jcenter()
}

testSets {
  integrationTest {
    dirName = 'integration-test'
  }
}

dependencies {
  compile(
    'com.google.code.gson:gson:2.8.5',
    'com.squareup.okhttp3:okhttp:3.11.0',
    'com.datadoghq:java-dogstatsd-client:2.4',
    'commons-io:commons-io:2.6',
    'net.logstash.logback:logstash-logback-encoder:5.+',
    'org.projectlombok:lombok:1.18.4',
    'org.springframework.boot:spring-boot-configuration-processor',
    'org.springframework.boot:spring-boot-starter-actuator',
    'org.springframework.boot:spring-boot-starter-data-cassandra',
    'org.springframework.boot:spring-boot-starter-integration',
    'org.springframework.boot:spring-boot-starter-web',
  )

  testCompile(
    'com.google.guava:guava:27.0-jre',
    'org.springframework.boot:spring-boot-starter-test',
    'uk.org.lidalia:slf4j-test:1.1.0',
  )

  integrationTestCompile(
    'org.cassandraunit:cassandra-unit-spring:3.5.0.1',
    'org.cassandraunit:cassandra-unit-shaded:3.5.0.1',
  )
}

configurations.integrationTestCompile {
  exclude group: 'uk.org.lidalia'
}

compileJava.dependsOn(processResources)

// JaCoCo Configuration

jacoco {
  toolVersion = "0.8.1"
}

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

  afterEvaluate {
    classDirectories = files(classDirectories.files.collect {
      fileTree(dir: it,
        exclude: ['**/model/**',
                  '**/model/**',
                  '**/config/**',
                  '**/constants/**',
                  '**/Webepository.class',
                  '**/Application.class'])
    })
  }
}

test {
  description "Runs all unit tests"

  include "**/*Test.class"
  maxParallelForks = 4
  mustRunAfter 'precheck'
}

task testIntegration(type: Test) {
  description "Runs all integration tests"

  # probably need to fix here something
  group = 'verification'
  testClassesDirs = sourceSets.integrationTest.output.classesDirs
  classpath = sourceSets.integrationTest.runtimeClasspath
  mustRunAfter 'test'

//  testLogging {
//    showStandardStreams = true
//  }
}

task precheck {
  dependsOn 'checkstyleMain'
  dependsOn 'checkstyleTest'
  dependsOn 'findbugsMain'
  dependsOn 'findbugsTest'
}

task precommit {
  dependsOn 'precheck'
  dependsOn 'check'
  dependsOn 'test'
  dependsOn 'testIntegration'
}

jacocoTestCoverageVerification {
  violationRules {
    rule {
      element = 'PACKAGE'
      excludes = [
        ‘package.model',
        ‘package.model.*'      ]
      limit {
        counter = 'BRANCH'
        minimum = 0.7
      }
    }
  }
}

checkstyle {
  toolVersion = '8.11'
  ignoreFailures = false
  configFile = file("${project.projectDir}/checkstyle/google_checks.xml")
  configProperties = ['basedir': "${project.projectDir}/checkstyle/"]
}

findbugs {
  toolVersion = "3.0.1"
  ignoreFailures = false
  reportsDir = file("${project.buildDir}/findbugsReports")
  effort = "max"
  reportLevel = "high"
}

tasks.withType(FindBugs) {
  reports {
    xml.enabled = false
    html.enabled = true
  }
}

distributions {
  main {
    baseName = "${applicationName}"
  }
}

test.onlyIf { !Boolean.getBoolean('skip.tests') }
testIntegration.onlyIf { !Boolean.getBoolean('skip.tests') }
checkstyleMain.onlyIf { !Boolean.getBoolean('skip.tests') }
checkstyleTest.onlyIf { !Boolean.getBoolean('skip.tests') }
check.dependsOn testIntegration
//test.finalizedBy jacocoTestReport
//check.dependsOn jacocoTestReport
//check.dependsOn jacocoTestCoverageVerification
//jacocoTestCoverageVerification.mustRunAfter jacocoTestReport

以上是关于text 弹簧靴的Gradle模板。展示如何使用集成测试的主要内容,如果未能解决你的问题,请参考以下文章

使用的表型弹簧靴的最大行数。

如何通过带有弹簧靴的邮递员操作数据

带弹簧靴的执行器

带有弹簧靴的rabbitmq中的异常

带有弹簧靴的keycloak openid单次注销

用于弹簧靴的 CORS 过滤器不起作用