How to use evaluate method of io.kotest.property.Constraints class

Best Kotest code snippet using io.kotest.property.Constraints.evaluate

build.gradle.kts

Source:build.gradle.kts Github

copy

Full Screen

1/*2 * Copyright (C) 2016 - present Juergen Zimmermann, Hochschule Karlsruhe3 *4 * This program is free software: you can redistribute it and/or modify5 * it under the terms of the GNU General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * (at your option) any later version.8 *9 * This program is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU General Public License for more details.13 *14 * You should have received a copy of the GNU General Public License15 * along with this program. If not, see <https://www.gnu.org/licenses/>.16 */17// Aufrufe18// 1) Microservice uebersetzen und starten19// .\gradlew bootRun [--args='--debug'] [--continuous]20// .\gradlew compileKotlin21// .\gradlew compileTestKotlin22//23// 2) Microservice als selbstausfuehrendes JAR erstellen und ausfuehren24// .\gradlew bootJar25// java -jar build/libs/....jar --spring.profiles.active=dev26// .\gradlew jibDockerBuild [-D'tag=2.0.0'] [-Ddebug=true]27// .\gradlew bootBuildImage28// erfordert die lokale Windows-Gruppe docker-users29// docker run --publish 8080:8080 --env TZ=Europe/Berlin --name dok --rm dok:1.0-GraalVM30// curl --silent http://localhost:808031//32// 3) Tests und QS33// .\gradlew test [--rerun-tasks] [--fail-fast]34// EINMALIG>> .\gradlew downloadAllure35// .\gradlew allureServe36// .\gradlew ktlint detekt37//38// 4) Sicherheitsueberpruefung durch OWASP Dependency Check und Snyk39// .\gradlew dependencyCheckAnalyze --info40// .\gradlew snyk-test41//42// 5) "Dependencies Updates"43// .\gradlew versions44// .\gradlew dependencyUpdates45//46// 6) API-Dokumentation erstellen (funktioniert NICHT mit proxy.hs-karlruhe.de, sondern nur mit proxyads)47// .\gradlew dokkaHtml48//49// 7) Entwicklerhandbuch in "Software Engineering" erstellen50// .\gradlew asciidoctor asciidoctorPdf51// .\gradlew jigReports52//53// 8) Projektreport erstellen54// .\gradlew projectReport55// .\gradlew dependencyInsight --dependency spring-security-rsa56// .\gradlew dependencies57// .\gradlew dependencies --configuration runtimeClasspath58// .\gradlew buildEnvironment59// .\gradlew htmlDependencyReport60//61// 9) Report ueber die Lizenzen der eingesetzten Fremdsoftware62// .\gradlew generateLicenseReport63//64// 10) Daemon stoppen65// .\gradlew --stop66//67// 11) Verfuegbare Tasks auflisten68// .\gradlew tasks69//70// 12) Initialisierung des Gradle Wrappers in der richtigen Version71// (dazu ist ggf. eine Internetverbindung erforderlich)72// gradle wrapper --gradle-version=6.8 --distribution-type=all73// https://github.com/gradle/kotlin-dsl/tree/master/samples74// https://docs.gradle.org/current/userguide/kotlin_dsl.html75// https://docs.gradle.org/current/userguide/task_configuration_avoidance.html76// https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin77plugins {78 //`kotlin-dsl`79 java80 idea81 jacoco82 `project-report`83 // org.jetbrains.kotlin:kotlin-gradle-plugin84 kotlin("jvm") version Versions.Plugins.kotlin85 // fuer Spring Beans: org.jetbrains.kotlin:kotlin-allopen86 kotlin("plugin.allopen") version Versions.Plugins.allOpen87 // fuer @ConfigurationProperties mit "data class": org.jetbrains.kotlin:kotlin-noarg88 kotlin("plugin.noarg") version Versions.Plugins.noArg89 // Voraussetzung fuer spring-context-indexer: org.jetbrains.kotlin:kotlin-annotation-processing-gradle90 kotlin("kapt") version Versions.Plugins.kapt91 id("org.springframework.boot") version Versions.Plugins.springBoot92 id("com.adarshr.test-logger") version Versions.Plugins.testLogger93 // https://github.com/allure-framework/allure-gradle94 // https://docs.qameta.io/allure/#_gradle_295 // https://github.com/allure-framework/allure-gradle/issues/5296 id("io.qameta.allure") version Versions.Plugins.allure97 // https://github.com/chrisgahlert/gradle-dcompose-plugin98 //id("com.chrisgahlert.gradle-dcompose-plugin") version Versions.Plugins.dcompose99 id("com.fizzpod.sweeney") version Versions.Plugins.sweeney100 // https://github.com/arturbosch/detekt101 id("io.gitlab.arturbosch.detekt") version Versions.Plugins.detekt102 // https://github.com/Kotlin/dokka103 // FIXME https://github.com/Kotlin/dokka/issues/1255104 id("org.jetbrains.dokka") version Versions.Plugins.dokka105 // https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin106 id("com.google.cloud.tools.jib") version Versions.Plugins.jib107 // https://github.com/jeremylong/dependency-check-gradle108 id("org.owasp.dependencycheck") version Versions.Plugins.owaspDependencyCheck109 // https://github.com/snyk/gradle-plugin110 id("io.snyk.gradle.plugin.snykplugin") version Versions.Plugins.snyk111 // https://github.com/asciidoctor/asciidoctor-gradle-plugin112 // FIXME https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/583113 id("org.asciidoctor.jvm.convert") version Versions.Plugins.asciidoctorConvert114 id("org.asciidoctor.jvm.pdf") version Versions.Plugins.asciidoctorPdf115 // Leanpub als Alternative zu PDF: https://github.com/asciidoctor/asciidoctor-leanpub-converter116 // https://github.com/dddjava/jig117 id("org.dddjava.jig-gradle-plugin") version Versions.Plugins.jig118 // https://github.com/nwillc/vplugin119 id("com.github.nwillc.vplugin") version Versions.Plugins.vplugin120 // https://github.com/ben-manes/gradle-versions-plugin121 id("com.github.ben-manes.versions") version Versions.Plugins.versions122 // https://github.com/jk1/Gradle-License-Report123 // FIXME https://github.com/jk1/Gradle-License-Report/issues/176124 id("com.github.jk1.dependency-license-report") version Versions.Plugins.jk1DependencyLicenseReport125 // https://github.com/jaredsburrows/gradle-license-plugin126 // erfordert Repository fuer Android127 //id("com.jaredsburrows.license") version Versions.Plugins.jaredsBurrowsLicense128 // https://github.com/hierynomus/license-gradle-plugin129 //id("com.github.hierynomus.license") version Versions.Plugins.hierynomusLicense130 // https://github.com/intergamma/gradle-zap131 //id("net.intergamma.gradle.gradle-zap-plugin") version Versions.Plugins.zap132}133defaultTasks = mutableListOf("compileTestKotlin")134group = "com.acme"135version = "1.0.0"136// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/html/#build-image-example-builder-configuration137// https://github.com/paketo-buildpacks/bellsoft-liberica#configuration138// fuer Cloud Native Buildpack innerhalb der Task "bootBuildImage"139java.sourceCompatibility = Versions.javaSourceCompatibility140repositories {141 mavenCentral()142 jcenter()143 maven("https://dl.bintray.com/kotlin/kotlin-eap")144 //maven("https://dl.bintray.com/kotlin/kotlin-dev") {145 // mavenContent { snapshotsOnly() }146 //}147 // https://github.com/spring-projects/spring-framework/wiki/Spring-repository-FAQ148 // https://github.com/spring-projects/spring-framework/wiki/Release-Process149 maven("https://repo.spring.io/milestone") {150 mavenContent { releasesOnly() }151 }152 maven("https://repo.spring.io/release") {153 mavenContent { releasesOnly() }154 }155 // Snapshots von Spring Framework, Spring Boot, Spring Data und Spring Security156 //maven("https://repo.spring.io/snapshot") {157 // mavenContent { snapshotsOnly() }158 //}159 // Snapshots von JaCoCo160 //maven("https://oss.sonatype.org/content/repositories/snapshots") {161 // mavenContent { snapshotsOnly() }162 //}163}164/** Konfiguration fuer ktlint */165val ktlintCfg: Configuration by configurations.creating166// https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation167dependencies {168 // https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:bom_import169 // https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-bom/pom.xml170 //implementation(platform("org.jetbrains.kotlin:kotlin-bom:${Versions.kotlin}"))171 implementation(platform("org.jetbrains.kotlin:kotlin-bom:${Versions.Plugins.kotlin}"))172 //implementation(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:${Versions.kotlinCoroutines}"))173 implementation(platform("org.apache.logging.log4j:log4j-bom:${Versions.log4j2}"))174 //implementation(platform("org.junit:junit-bom:${Versions.junitJupiterBom}"))175 //implementation(platform("io.projectreactor:reactor-bom:${Versions.reactorBom}"))176 implementation(platform("com.fasterxml.jackson:jackson-bom:${Versions.jackson}"))177 //implementation(platform("org.springframework:spring-framework-bom:${Versions.springBom}"))178 implementation(platform("org.springframework.data:spring-data-bom:${Versions.springDataBom}"))179 implementation(platform("org.springframework.security:spring-security-bom:${Versions.springSecurityBom}"))180 implementation(platform("org.springframework.boot:spring-boot-starter-parent:${Versions.springBoot}"))181 // https://github.com/spring-projects-experimental/spring-graalvm-native182 // https://github.com/spring-projects-experimental/spring-graalvm-native/blob/master/spring-graalvm-native-docs/src/main/asciidoc/support.adoc183 // https://repo.spring.io/milestone/org/springframework/experimental/spring-graalvm-native-docs/0.8.0/spring-graalvm-native-docs-0.8.0.zip!/reference/index.html184 // https://github.com/oracle/graal/issues?q=is%3Aissue+is%3Aopen+label%3Aspring185 // Project Leyden: https://mail.openjdk.java.net/pipermail/discuss/2020-April/005429.html186 //implementation("org.springframework.experimental:spring-graalvm-native:${Versions.springGraalvmNative}")187 // kotlinx.reflect.lite unterstuetzt nur Namen von Parametern und deren Nullability188 implementation(kotlin("reflect"))189 implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")190 implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")191 // "Starters" enthalten sinnvolle Abhaengigkeiten, die man i.a. benoetigt192 implementation("org.springframework.boot:spring-boot-starter")193 implementation("org.springframework.boot:spring-boot-starter-log4j2")194 implementation("org.springframework.boot:spring-boot-starter-webflux")195 implementation("org.springframework.boot:spring-boot-starter-tomcat")196 implementation("org.springframework.boot:spring-boot-starter-json")197 implementation("org.springframework.hateoas:spring-hateoas")198 implementation("org.springframework.boot:spring-boot-starter-validation")199 implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")200 implementation("org.springframework.boot:spring-boot-starter-security")201 implementation("org.springframework.boot:spring-boot-starter-mail")202 implementation("org.springframework.boot:spring-boot-starter-actuator")203 implementation("org.springframework.boot:spring-boot-starter-thymeleaf")204 implementation("com.fasterxml.jackson.module:jackson-module-kotlin")205 // https://logging.apache.org/log4j/2.x/manual/layouts.html#enable-jansi206 implementation("org.fusesource.jansi:jansi:${Versions.jansi}")207 // https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging208 implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")209 // https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-kotlin-configuration-properties210 // https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-configuration-metadata.html#configuration-metadata-annotation-processor211 // META-INF\additional-spring-configuration-metadata.json212 kapt("org.springframework.boot:spring-boot-configuration-processor:${Versions.springBoot}")213 // Java statt Kotlin:214 //annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:${Versions.springBoot}")215 // https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-scanning-index216 // generiert Index-Datei META-INF/spring.components (in build\tmp\kapt3\classes\main\META-INF) statt Scanning des Classpath217 kapt("org.springframework:spring-context-indexer:${Versions.springBom}")218 // Java statt Kotlin:219 //compileOnly("org.springframework:spring-context-indexer")220 // https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#using-boot-devtools221 // https://www.vojtechruzicka.com/spring-boot-devtools222 //runtimeOnly("org.springframework.boot:spring-boot-devtools:${Versions.springBoot}")223 testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test")224 testImplementation("io.kotest:kotest-assertions-core:${Versions.kotest}")225 testImplementation("io.mockk:mockk:${Versions.mockk}")226 testImplementation("org.springframework.boot:spring-boot-starter-test") {227 exclude(group = "org.assertj", module = "assertj-core")228 exclude(group = "org.hamcrest", module = "hamcrest")229 exclude(group = "org.mockito", module = "mockito-core")230 exclude(group = "org.mockito", module = "mockito-junit-jupiter")231 exclude(group = "org.skyscreamer", module = "jsonassert")232 exclude(group = "org.xmlunit", module = "xmlunit-core")233 }234 testImplementation("org.springframework.security:spring-security-test")235 //testImplementation("org.testcontainers:mongodb")236 //testImplementation("org.testcontainers:junit-jupiter")237 ktlintCfg("com.pinterest:ktlint:${Versions.ktlint}")238 dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:${Versions.Plugins.dokka}")239 // https://youtrack.jetbrains.net/issue/KT-27463240 @Suppress("UnstableApiUsage")241 constraints {242 //implementation("org.springframework.hateoas:spring-hateoas:${Versions.springHateoas}")243 //implementation("org.springframework.data:spring-data-mongodb:${Versions.springDataMongoDB}")244 implementation("org.springframework.security:spring-security-rsa:${Versions.springSecurityRsa}")245 implementation("org.jetbrains:annotations:${Versions.annotations}")246 //implementation("org.reactivestreams:reactive-streams:${Versions.reactiveStreams}")247 implementation("org.hibernate.validator:hibernate-validator:${Versions.hibernateValidator}")248 implementation("org.mongodb:mongodb-driver-core:${Versions.mongodb}")249 implementation("org.mongodb:mongodb-driver-reactivestreams:${Versions.mongoDriverReactivestreams}")250 implementation("io.netty:netty-codec-http:${Versions.nettyCodecHttp}")251 //implementation("org.apache.tomcat.embed:tomcat-embed-core:${Versions.tomcat}")252 //implementation("org.apache.tomcat.embed:tomcat-embed-el:${Versions.tomcat}")253 implementation("org.thymeleaf:thymeleaf-spring5:${Versions.thymeleaf}")254 ktlintCfg("org.jetbrains:annotations:${Versions.annotations}")255 ktlintCfg("org.jetbrains.kotlin:kotlin-stdlib:${Versions.ktlintKotlin}")256 ktlintCfg("org.jetbrains.kotlin:kotlin-compiler-embeddable:${Versions.ktlintKotlin}")257 ktlintCfg("org.apache.httpcomponents:httpclient:${Versions.httpClientKtlint}")258 }259}260configurations.all {261 // https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-configure-log4j-for-logging262 // https://blog.frankel.ch/feedback-log4j2-hack-spring-boot263 exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")264 // aktuelle Snapshots laden265 //resolutionStrategy { cacheChangingModulesFor(0, "seconds") }266}267allOpen {268 annotation("org.springframework.stereotype.Component")269 annotation("org.springframework.stereotype.Service")270 annotation("org.springframework.boot.context.properties.ConfigurationProperties")271}272noArg {273 annotation("org.springframework.boot.context.properties.ConfigurationProperties")274}275sweeney {276 enforce(mapOf("type" to "gradle", "expect" to "[6.7,7)"))277 // https://devcenter.heroku.com/articles/java-support#specifying-a-java-version278 enforce(279 mapOf(280 "type" to "jdk",281 "expect" to "[${Versions.javaMin},${Versions.javaMax}]"282 )283 )284 validate()285}286// https://kotlinlang.org/docs/reference/whatsnew14.html#explicit-api-mode-for-library-authors287//kotlin {288// explicitApi()289//}290tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {291 kotlinOptions {292 apiVersion = "1.4"293 languageVersion = "1.4"294 jvmTarget = Versions.kotlinJvmTarget295 verbose = true296 // https://docs.gradle.org/6.6/userguide/kotlin_dsl.html#sec:kotlin_compiler_arguments297 // https://kotlinlang.org/docs/reference/whatsnew14.html#new-modes-for-generating-default-methods298 // "-Xjvm-default=all"299 // "-Xjvm-default=all-compatibility"300 freeCompilerArgs = listOfNotNull("-Xjsr305=strict", "-Xstring-concat=indy-with-constants", "-Xinline-classes")301 // https://kotlinlang.org/docs/reference/whatsnew14.html#new-jvm-ir-backend302 // IndexOutOfBoundsException beim Uebersetzen von Router.kt303 //useIR = true304 //allWarningsAsErrors = true305 // ggf. wegen Kotlin-Daemon: %TEMP%\kotlin-daemon.* und %LOCALAPPDATA%\kotlin\daemon306 // https://youtrack.jetbrains.com/issue/KT-18300307 // $env:LOCALAPPDATA\kotlin\daemon308 // $env:TEMP\kotlin-daemon.<ZEITSTEMPEL>309 }310}311tasks.compileTestKotlin {312 kotlinOptions {313 // https://play.kotlinlang.org/hands-on/Introduction%20to%20Coroutines%20and%20Channels/09_Testing314 @Suppress("SuspiciousCollectionReassignment")315 freeCompilerArgs += "-Xuse-experimental=kotlin.Experimental"316 }317}318// META-INF\additional-spring-configuration-metadata.json319//tasks.compileJava.inputs.files(processResources)320tasks.bootJar {321 doLast {322 println("")323 println("Aufruf der ausfuehrbaren JAR-Datei:")324 println("java -D'java.util.logging.manager=org.apache.logging.log4j.jul.LogManager' -D'log4j.skipJansi=false' -D'LOG_PATH=./build/log' -D'javax.net.ssl.trustStore=./src/main/resources/truststore.p12' -D'javax.net.ssl.trustStorePassword=zimmermann' -jar build/libs/${archiveFileName.get()} --spring.profiles.active=dev")325 println("")326 }327}328tasks.bootBuildImage {329 // "created 40 years ago" wegen Reproducability: https://medium.com/buildpacks/time-travel-with-pack-e0efd8bf05db330 // default:331 //imageName = "docker.io/${project.name}:${project.version}"332 // "latest" statt Versionsnummer des Projekts:333 //imageName = "docker.io/${project.name}"334 val dockerAccount = "juergenzimmermann"335 val tag = System.getProperty("tag") ?: project.version336 imageName = "docker.io/${dockerAccount}/${project.name}:$tag"337 // https://github.com/bell-sw/Liberica/releases338 // default: ALWAYS339 //pullPolicy = org.springframework.boot.buildpack.platform.build.PullPolicy.IF_NOT_PRESENT340 // Native Image mit GraalVM:341 // https://github.com/paketo-buildpacks/spring-boot-native-image342 // https://github.com/paketo-buildpacks/builder343 // https://paketo.io/docs/getting-started/where-do-buildpacks-factor-in344 // https://repo.spring.io/milestone/org/springframework/experimental/spring-graalvm-native-docs/0.8.0/spring-graalvm-native-docs-0.8.0.zip!/reference/index.html#_graalvm_options345 // https://github.com/spring-projects-experimental/spring-graalvm-native/blob/master/spring-graalvm-native-samples/webmvc-kotlin/build.gradle.kts346 // Image-Groesse: Default Builder ~600 MB, Tiny Builder ~400 MB347 //builder = "paketobuildpacks/builder:tiny"348 //environment = mapOf(349 // "BP_BOOT_NATIVE_IMAGE" to "1",350 // "BP_BOOT_NATIVE_IMAGE_BUILD_ARGUMENTS" to """351 // -Dspring.spel.ignore=true352 // -H:+ReportExceptionStackTraces353 // """.trimIndent()354 // // evtl. -H:+TraceClassInitialization355 // // evtl. --initialize-at-build-time fuer Netty356 //)357}358// https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin359// https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#why-is-my-image-created-48-years-ago360jib {361 val debug = System.getProperty("debug") ?: false.toString()362 from {363 // Cache fuer Images und Layers: ${env:LOCALAPPDATA}\Local\Google\Jib\Cache364 // Ein "distroless image" enthaelt keine Package Manager, Shells, usw., sondern nur in der Variante -debug365 // d.h. ca. 200 MB statt ca. 450 MB366 // https://console.cloud.google.com/gcr/images/distroless367 image = "gcr.io/distroless/java-debian10:${Versions.jibJava}"368 if (debug.toBoolean()) {369 image += "-debug"370 }371 }372 to {373 val dockerAccount = "juergenzimmermann"374 val tag = System.getProperty("tag") ?: project.version375 image = "docker.io/${dockerAccount}/${project.name}:$tag"376 if (debug.toBoolean()) {377 image += "-debug"378 }379 }380 container {381 // "nonroot", siehe /etc/passwd382 user = "65532:65532"383 // Default: com.google.cloud.tools.jib.api.buildplan.ImageFormat.Docker384 //format = com.google.cloud.tools.jib.api.buildplan.ImageFormat.OCI385 //creationTime = "USE_CURRENT_TIMESTAMP"386 // https://github.com/GoogleContainerTools/jib/blob/master/docs/faq.md#jvm-flags387 jvmFlags = listOf(388 "-Dspring.config.location=classpath:/application.yml",389 "-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager",390 "-Dlog4j.skipJansi=false"391 )392 }393 // https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#extended-usage Umgebungsvariable394 // https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin#system-properties395}396tasks.jibDockerBuild.get().setDependsOn(listOf(tasks.bootJar))397tasks.bootRun {398 systemProperties = mapOf(399 "java.util.logging.manager" to "org.apache.logging.log4j.jul.LogManager",400 "log4j.skipJansi" to "false"401 )402 // Umgebungsvariable, z.B. fuer Spring Properties oder fuer log4j2.yml403 environment("LOG_PATH", "./build/log")404 environment("APPLICATION_LOGLEVEL", "trace")405 args(406 "--spring.profiles.active=dev",407 "--spring.output.ansi.enabled=ALWAYS",408 "--spring.config.location=classpath:/application.yml",409 "--spring.data.mongodb.password=p"410 )411 // Hotspot Compiler fuer aggressivere Optimierung als der Client-Compiler, aber laengere Startzeit: -server"412 // Remote Debugger: .\gradlew bootRun --debug-jvm -verbose:class -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005413}414tasks.test {415 useJUnitPlatform {416 includeEngines("junit-jupiter")417 includeTags("rest", "fileRest", "streamingRest", "service")418 //includeTags("rest")419 //includeTags("fileRest")420 //includeTags("streamingRest")421 //includeTags("service")422 //excludeTags("service")423 }424 //filter {425 // includeTestsMatching(includeTests)426 //}427 systemProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager")428 systemProperty("log4j.skipJansi", false)429 systemProperty("WEBAPP_CLASS_LOADER_BASE_LOGLEVEL", "error")430 systemProperty("javax.net.ssl.trustStore", "./src/main/resources/truststore.p12")431 systemProperty("javax.net.ssl.trustStorePassword", "zimmermann")432 systemProperty("junit.platform.output.capture.stdout", true)433 systemProperty("junit.platform.output.capture.stderr", true)434 systemProperty("spring.config.location", "./src/main/resources/application.yml")435 //systemProperty("org.aspectj.tracing.enabled", false)436 //systemProperty("org.aspectj.tracing.messages", false)437 // Umgebungsvariable, z.B. fuer Spring Properties oder fuer log4j2.yml438 environment("spring.data.mongodb.password", "p")439 environment("LOG_PATH", "./build/log")440 environment("APPLICATION_LOGLEVEL", "trace")441 // https://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests442 // https://www.jetbrains.com/help/idea/run-debug-configuration-junit.html443 // https://docs.gradle.org/current/userguide/java_testing.html#sec:debugging_java_tests444 //debug = true445 // damit nach den Tests immer ein HTML-Report von JaCoCo erstellt wird446 // https://github.com/gradle/gradle/pull/12626447 finalizedBy(tasks.jacocoTestReport)448}449// https://docs.qameta.io/allure/#_gradle_2450allure {451 autoconfigure = true452 configuration = "testImplementation"453 version = Versions.allure454 useJUnit5 { version = Versions.allureJunit }455 //downloadLink = "https://repo1.maven.org/maven2/io/qameta/allure/allure-commandline/${Versions.allureCommandline}/allure-commandline-${Versions.allureCommandline}.zip"456}457jacoco {458 toolVersion = Versions.jacocoVersion459}460// https://docs.gradle.org/current/userguide/task_configuration_avoidance.html461// https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/#configuring-tasks462tasks.getByName<JacocoReport>("jacocoTestReport") {463 reports {464 xml.isEnabled = true465 html.isEnabled = true466 }467 // afterEvaluate gibt es nur bei getByName<> ("eager"), nicht bei named<> ("lazy")468 // https://docs.gradle.org/5.0/release-notes.html#configuration-avoidance-api-disallows-common-configuration-errors469 afterEvaluate {470 classDirectories.setFrom(files(classDirectories.files.map {471 fileTree(it) { exclude("**/config/**", "**/entity/**") }472 }))473 }474 // https://github.com/gradle/gradle/pull/12626475 dependsOn(tasks.test)476}477// https://ktlint.github.io/#getting-started478// https://android.github.io/kotlin-guides/style.html479// https://kotlinlang.org/docs/reference/coding-conventions.html480// https://www.jetbrains.com/help/idea/code-style-kotlin.html481// https://github.com/android/kotlin-guides/issues/37482// https://github.com/shyiko/ktlint483@Suppress("KDocMissingDocumentation")484val ktlint by tasks.register<JavaExec>("ktlint") {485 group = "verification"486 classpath = ktlintCfg487 main = "com.pinterest.ktlint.Main"488 // https://github.com/pinterest/ktlint/blob/master/ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt489 args = listOfNotNull(490 "--verbose",491 "--experimental",492 "--relative",493 "--color",494 "--reporter=plain",495 "--reporter=checkstyle,output=$buildDir/reports/ktlint.xml",496 "src/**/*.kt"497 )498}499tasks.check { dependsOn(ktlint) }500/*501tasks {502 withType<Detekt> {503 //this.jvmTarget = "1.8"504 this.jvmTarget = Versions.kotlinJvmTarget505 }506}507*/508detekt {509 @Suppress("UnstableApiUsage")510 input = objects.fileCollection().from(511 "src/main/kotlin",512 "src/test/kotlin"513 )514 buildUponDefaultConfig = true515 failFast = true516 parallel = true517 config = files(project.rootDir.resolve("config/detekt.yaml"))518 reports {519 val reportsDir = "$buildDir/reports"520 xml { destination = file("$reportsDir/detekt.xml") }521 html { destination = file("$reportsDir/detekt.html") }522 txt { enabled = false }523 }524}525// https://github.com/jeremylong/DependencyCheck/blob/master/src/site/markdown/dependency-check-gradle/configuration.md526// https://github.com/jeremylong/DependencyCheck/issues/1732527dependencyCheck {528 scanConfigurations = listOfNotNull("runtimeClasspath")529 suppressionFile = "$projectDir/config/owasp.xml"530 data(closureOf<org.owasp.dependencycheck.gradle.extension.DataExtension> {531 directory = "C:/Zimmermann/owasp-dependency-check"532 username = "dc"533 password = "p"534 })535 analyzedTypes = listOfNotNull("jar")536 analyzers(closureOf<org.owasp.dependencycheck.gradle.extension.AnalyzerExtension> {537 // nicht benutzte Analyzer538 assemblyEnabled = false539 autoconfEnabled = false540 bundleAuditEnabled = false541 cmakeEnabled = false542 cocoapodsEnabled = false543 composerEnabled = false544 golangDepEnabled = false545 golangModEnabled = false546 nodeEnabled = false547 nugetconfEnabled = false548 nuspecEnabled = false549 pyDistributionEnabled = false550 pyPackageEnabled = false551 rubygemsEnabled = false552 swiftEnabled = false553 nodeAudit(closureOf<org.owasp.dependencycheck.gradle.extension.NodeAuditExtension> { enabled = true })554 retirejs(closureOf<org.owasp.dependencycheck.gradle.extension.RetireJSExtension> { enabled = true })555 //ossIndex(closureOf<org.owasp.dependencycheck.gradle.extension.OssIndexExtension> { enabled = true })556 })557 format = org.owasp.dependencycheck.reporting.ReportGenerator.Format.ALL558}559snyk {560 setArguments("--all-sub-projects")561 setSeverity("low")562 setApi("40df2078-e1a3-4f28-b913-e2babbe427fd")563 //setApi("12345678-1234-1234-1234-123456789012")564}565// SVG-Dateien von AsciidoctorPdf fuer Dokka umkopieren566@Suppress("KDocMissingDocumentation")567val copySvg by tasks.register<Copy>("copySvg") {568 from("$buildDir/docs/asciidocPdf")569 include("*.svg")570 into("$buildDir/dokka/html/images")571 dependsOn("asciidoctorPdf")572}573// https://github.com/Kotlin/dokka/blob/master/docs/src/doc/docs/user_guide/gradle/usage.md574tasks.dokkaHtml {575 // When this is set to default, caches are stored in $USER_HOME/.cache/dokka576 cacheRoot.set(file("$buildDir/dokka/cache"))577 dokkaSourceSets {578 configureEach {579 // FIXME https://github.com/Kotlin/dokka/issues/1662580 // includes.from("Module.md")581 apiVersion.set("1.4")582 //languageVersion.set(apiVersion)583 reportUndocumented.set(true)584 jdkVersion.set(Versions.kotlinJvmTarget.toInt())585 noStdlibLink.set(true)586 noJdkLink.set(true)587 //suppressedFiles.from(588 // "src/main/kotlin/entity/Dok.kt",589 // "src/main/kotlin/security/CustomUser.kt",590 // "src/main/kotlin/security/CustomUserDetailsService.kt",591 //)592 }593 }594 dependsOn("createDokkaCacheDirectory", copySvg)595}596tasks.register("createDokkaCacheDirectory") {597 doLast { mkdir("$buildDir/dokka/cache") }598}599tasks.asciidoctor {600 asciidoctorj {601 setVersion(Versions.asciidoctorj)602 //requires("asciidoctor-diagram")603 modules {604 diagram.use()605 diagram.setVersion(Versions.asciidoctorjDiagram)606 }607 }608 setBaseDir(file("doc"))609 setSourceDir(file("doc"))610 //setOutputDir(file("$buildDir/docs/asciidoc"))611 logDocuments = true612 doLast {613 val separator = System.getProperty("file.separator")614 println("Das Entwicklerhandbuch ist in $buildDir${separator}docs${separator}asciidoc${separator}entwicklerhandbuch.html")615 }616}617tasks.asciidoctorPdf {618 asciidoctorj {619 setVersion(Versions.asciidoctorj)620 modules {621 diagram.use()622 diagram.setVersion(Versions.asciidoctorjDiagram)623 pdf.setVersion(Versions.asciidoctorjPdf)624 }625 }626 setBaseDir(file("doc"))627 setSourceDir(file("doc"))628 attributes(mapOf("pdf-page-size" to "A4"))629 logDocuments = true630 doLast {631 val separator = System.getProperty("file.separator")632 println("Das Entwicklerhandbuch ist in $buildDir${separator}docs${separator}asciidocPdf${separator}entwicklerhandbuch.pdf")633 }634}635// FIXME Wie konfigurieren ???636jig {637 modelPattern = ".+\\.domain\\.(model|type)\\..+"638 outputOmitPrefix = ".+\\.(service|domain\\.(model|type))\\."639}640licenseReport {641 configurations = arrayOf("runtimeClasspath")642}643tasks.dependencyUpdates {644 checkConstraints = true645}646idea {647 module {648 isDownloadJavadoc = true649 }650}...

Full Screen

Full Screen

proptest.kt

Source:proptest.kt Github

copy

Full Screen

...21 val random = createRandom(config)22 when (genA) {23 is Arb -> {24 genA.generate(random, config.edgeConfig)25 .takeWhile { constraints.evaluate() }26 .forEach { a ->27 val shrinkfn = shrinkfn(a, property, config.shrinkingMode)28 config.listeners.forEach { it.beforeTest() }29 test(30 context,31 config,32 shrinkfn,33 listOf(a.value),34 listOf(genA.classifier),35 random.seed36 ) {37 context.property(a.value)38 }39 config.listeners.forEach { it.afterTest() }40 }41 }42 is Exhaustive -> {43 genA.values.forEach { a ->44 config.listeners.forEach { it.beforeTest() }45 test(46 context,47 config,48 { emptyList() },49 listOf(a),50 listOf(genA.classifier),51 random.seed52 ) {53 context.property(a)54 }55 config.listeners.forEach { it.afterTest() }56 }57 }58 }59 context.outputClassifications(1, config, random.seed)60 context.checkMaxSuccess(config, random.seed)61 return context62}63suspend fun <A, B> proptest(64 genA: Gen<A>,65 genB: Gen<B>,66 config: PropTestConfig,67 property: suspend PropertyContext.(A, B) -> Unit68): PropertyContext {69 config.checkFailOnSeed()70 val constraints = config.constraints71 ?: config.iterations?.let { Constraints.iterations(it) }72 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)73 val context = PropertyContext()74 val random = createRandom(config)75 if (genA is Exhaustive && genB is Exhaustive) {76 genA.values.forEach { a ->77 genB.values.forEach { b ->78 config.listeners.forEach { it.beforeTest() }79 test(80 context,81 config,82 { emptyList() },83 listOf(a, b),84 listOf(genA.classifier, genB.classifier),85 random.seed86 ) {87 context.property(a, b)88 }89 config.listeners.forEach { it.afterTest() }90 }91 }92 } else {93 genA.generate(random, config.edgeConfig)94 .zip(genB.generate(random, config.edgeConfig))95 .takeWhile { constraints.evaluate() }96 .forEach { (a, b) ->97 val shrinkfn = shrinkfn(a, b, property, config.shrinkingMode)98 config.listeners.forEach { it.beforeTest() }99 test(100 context,101 config,102 shrinkfn,103 listOf(a.value, b.value),104 listOf(genA.classifier, genB.classifier),105 random.seed106 ) {107 context.property(a.value, b.value)108 }109 config.listeners.forEach { it.afterTest() }110 }111 }112 context.outputClassifications(2, config, random.seed)113 context.checkMaxSuccess(config, random.seed)114 return context115}116suspend fun <A, B, C> proptest(117 genA: Gen<A>,118 genB: Gen<B>,119 genC: Gen<C>,120 config: PropTestConfig,121 property: suspend PropertyContext.(A, B, C) -> Unit122): PropertyContext {123 config.checkFailOnSeed()124 val constraints = config.constraints125 ?: config.iterations?.let { Constraints.iterations(it) }126 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)127 val context = PropertyContext()128 val random = createRandom(config)129 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive) {130 genA.values.forEach { a ->131 genB.values.forEach { b ->132 genC.values.forEach { c ->133 config.listeners.forEach { it.beforeTest() }134 test(135 context,136 config,137 { emptyList() },138 listOf(a, b, c),139 listOf(genA.classifier, genB.classifier, genC.classifier),140 random.seed141 ) {142 context.property(a, b, c)143 }144 config.listeners.forEach { it.afterTest() }145 }146 }147 }148 } else {149 genA.generate(random, config.edgeConfig)150 .zip(genB.generate(random, config.edgeConfig))151 .zip(genC.generate(random, config.edgeConfig))152 .takeWhile { constraints.evaluate() }153 .forEach { (ab, c) ->154 val (a, b) = ab155 val shrinkfn = shrinkfn(a, b, c, property, config.shrinkingMode)156 config.listeners.forEach { it.beforeTest() }157 test(158 context,159 config,160 shrinkfn,161 listOf(a.value, b.value, c.value),162 listOf(genA.classifier, genB.classifier, genC.classifier),163 random.seed164 ) {165 context.property(a.value, b.value, c.value)166 }167 config.listeners.forEach { it.afterTest() }168 }169 }170 context.outputClassifications(3, config, random.seed)171 context.checkMaxSuccess(config, random.seed)172 return context173}174suspend fun <A, B, C, D> proptest(175 genA: Gen<A>,176 genB: Gen<B>,177 genC: Gen<C>,178 genD: Gen<D>,179 config: PropTestConfig,180 property: suspend PropertyContext.(A, B, C, D) -> Unit181): PropertyContext {182 config.checkFailOnSeed()183 val constraints = config.constraints184 ?: config.iterations?.let { Constraints.iterations(it) }185 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)186 val context = PropertyContext()187 val random = createRandom(config)188 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive && genD is Exhaustive) {189 genA.values.forEach { a ->190 genB.values.forEach { b ->191 genC.values.forEach { c ->192 genD.values.forEach { d ->193 config.listeners.forEach { it.beforeTest() }194 test(195 context, config, { emptyList() }, listOf(a, b, c, d),196 listOf(genA.classifier, genB.classifier, genC.classifier, genD.classifier), random.seed197 ) {198 context.property(a, b, c, d)199 }200 config.listeners.forEach { it.afterTest() }201 }202 }203 }204 }205 } else {206 genA.generate(random, config.edgeConfig)207 .zip(genB.generate(random, config.edgeConfig))208 .zip(genC.generate(random, config.edgeConfig))209 .zip(genD.generate(random, config.edgeConfig))210 .takeWhile { constraints.evaluate() }211 .forEach { (abc, d) ->212 val (ab, c) = abc213 val (a, b) = ab214 val shrinkfn = shrinkfn(a, b, c, d, property, config.shrinkingMode)215 config.listeners.forEach { it.beforeTest() }216 test(217 context, config, shrinkfn,218 listOf(a.value, b.value, c.value, d.value),219 listOf(genA.classifier, genB.classifier, genC.classifier, genD.classifier),220 random.seed221 ) {222 context.property(a.value, b.value, c.value, d.value)223 }224 config.listeners.forEach { it.afterTest() }225 }226 }227 context.outputClassifications(4, config, random.seed)228 context.checkMaxSuccess(config, random.seed)229 return context230}231suspend fun <A, B, C, D, E> proptest(232 genA: Gen<A>,233 genB: Gen<B>,234 genC: Gen<C>,235 genD: Gen<D>,236 genE: Gen<E>,237 config: PropTestConfig,238 property: suspend PropertyContext.(A, B, C, D, E) -> Unit239): PropertyContext {240 config.checkFailOnSeed()241 val constraints = config.constraints242 ?: config.iterations?.let { Constraints.iterations(it) }243 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)244 val context = PropertyContext()245 val random = createRandom(config)246 if (genA is Exhaustive && genB is Exhaustive && genC is Exhaustive && genD is Exhaustive && genE is Exhaustive) {247 genA.values.forEach { a ->248 genB.values.forEach { b ->249 genC.values.forEach { c ->250 genD.values.forEach { d ->251 genE.values.forEach { e ->252 config.listeners.forEach { it.beforeTest() }253 test(254 context,255 config,256 { emptyList() },257 listOf(a, b, c, d, e),258 listOf(259 genA.classifier,260 genB.classifier,261 genC.classifier,262 genD.classifier,263 genE.classifier,264 ),265 random.seed266 ) {267 context.property(a, b, c, d, e)268 }269 config.listeners.forEach { it.afterTest() }270 }271 }272 }273 }274 }275 } else {276 genA.generate(random, config.edgeConfig)277 .zip(genB.generate(random, config.edgeConfig))278 .zip(genC.generate(random, config.edgeConfig))279 .zip(genD.generate(random, config.edgeConfig))280 .zip(genE.generate(random, config.edgeConfig))281 .takeWhile { constraints.evaluate() }282 .forEach { (abcd, e) ->283 val (abc, d) = abcd284 val (ab, c) = abc285 val (a, b) = ab286 val shrinkfn = shrinkfn(a, b, c, d, e, property, config.shrinkingMode)287 config.listeners.forEach { it.beforeTest() }288 test(289 context,290 config,291 shrinkfn,292 listOf(a.value, b.value, c.value, d.value, e.value),293 listOf(294 genA.classifier,295 genB.classifier,296 genC.classifier,297 genD.classifier,298 genE.classifier,299 ),300 random.seed301 ) {302 context.property(a.value, b.value, c.value, d.value, e.value)303 }304 config.listeners.forEach { it.afterTest() }305 }306 }307 context.outputClassifications(5, config, random.seed)308 context.checkMaxSuccess(config, random.seed)309 return context310}311suspend fun <A, B, C, D, E, F> proptest(312 genA: Gen<A>,313 genB: Gen<B>,314 genC: Gen<C>,315 genD: Gen<D>,316 genE: Gen<E>,317 genF: Gen<F>,318 config: PropTestConfig,319 property: suspend PropertyContext.(A, B, C, D, E, F) -> Unit320): PropertyContext {321 config.checkFailOnSeed()322 val constraints = config.constraints323 ?: config.iterations?.let { Constraints.iterations(it) }324 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)325 val context = PropertyContext()326 val random = createRandom(config)327 genA.generate(random, config.edgeConfig)328 .zip(genB.generate(random, config.edgeConfig))329 .zip(genC.generate(random, config.edgeConfig))330 .zip(genD.generate(random, config.edgeConfig))331 .zip(genE.generate(random, config.edgeConfig))332 .zip(genF.generate(random, config.edgeConfig))333 .takeWhile { constraints.evaluate() }334 .forEach { (abcde, f) ->335 val (abcd, e) = abcde336 val (abc, d) = abcd337 val (ab, c) = abc338 val (a, b) = ab339 val shrinkfn = shrinkfn(a, b, c, d, e, f, property, config.shrinkingMode)340 config.listeners.forEach { it.beforeTest() }341 test(342 context,343 config,344 shrinkfn,345 listOf(a.value, b.value, c.value, d.value, e.value, f.value),346 listOf(347 genA.classifier,348 genB.classifier,349 genC.classifier,350 genD.classifier,351 genE.classifier,352 genF.classifier,353 ),354 random.seed355 ) {356 context.property(a.value, b.value, c.value, d.value, e.value, f.value)357 }358 config.listeners.forEach { it.afterTest() }359 }360 context.outputClassifications(6, config, random.seed)361 context.checkMaxSuccess(config, random.seed)362 return context363}364suspend fun <A, B, C, D, E, F, G> proptest(365 genA: Gen<A>,366 genB: Gen<B>,367 genC: Gen<C>,368 genD: Gen<D>,369 genE: Gen<E>,370 genF: Gen<F>,371 genG: Gen<G>,372 config: PropTestConfig,373 property: suspend PropertyContext.(A, B, C, D, E, F, G) -> Unit374): PropertyContext {375 config.checkFailOnSeed()376 val constraints = config.constraints377 ?: config.iterations?.let { Constraints.iterations(it) }378 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)379 val context = PropertyContext()380 val random = createRandom(config)381 genA.generate(random, config.edgeConfig)382 .zip(genB.generate(random, config.edgeConfig))383 .zip(genC.generate(random, config.edgeConfig))384 .zip(genD.generate(random, config.edgeConfig))385 .zip(genE.generate(random, config.edgeConfig))386 .zip(genF.generate(random, config.edgeConfig))387 .zip(genG.generate(random, config.edgeConfig))388 .takeWhile { constraints.evaluate() }389 .forEach { (abcdef, g) ->390 val (abcde, f) = abcdef391 val (abcd, e) = abcde392 val (abc, d) = abcd393 val (ab, c) = abc394 val (a, b) = ab395 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, property, config.shrinkingMode)396 config.listeners.forEach { it.beforeTest() }397 test(398 context,399 config,400 shrinkfn,401 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value),402 listOf(403 genA.classifier,404 genB.classifier,405 genC.classifier,406 genD.classifier,407 genE.classifier,408 genF.classifier,409 genG.classifier410 ),411 random.seed412 ) {413 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value)414 }415 config.listeners.forEach { it.afterTest() }416 }417 context.outputClassifications(7, config, random.seed)418 context.checkMaxSuccess(config, random.seed)419 return context420}421suspend fun <A, B, C, D, E, F, G, H> proptest(422 genA: Gen<A>,423 genB: Gen<B>,424 genC: Gen<C>,425 genD: Gen<D>,426 genE: Gen<E>,427 genF: Gen<F>,428 genG: Gen<G>,429 genH: Gen<H>,430 config: PropTestConfig,431 property: suspend PropertyContext.(A, B, C, D, E, F, G, H) -> Unit432): PropertyContext {433 config.checkFailOnSeed()434 val constraints = config.constraints435 ?: config.iterations?.let { Constraints.iterations(it) }436 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)437 val context = PropertyContext()438 val random = createRandom(config)439 genA.generate(random, config.edgeConfig)440 .zip(genB.generate(random, config.edgeConfig))441 .zip(genC.generate(random, config.edgeConfig))442 .zip(genD.generate(random, config.edgeConfig))443 .zip(genE.generate(random, config.edgeConfig))444 .zip(genF.generate(random, config.edgeConfig))445 .zip(genG.generate(random, config.edgeConfig))446 .zip(genH.generate(random, config.edgeConfig))447 .takeWhile { constraints.evaluate() }448 .forEach { (abcdefg, h) ->449 val (abcdef, g) = abcdefg450 val (abcde, f) = abcdef451 val (abcd, e) = abcde452 val (abc, d) = abcd453 val (ab, c) = abc454 val (a, b) = ab455 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, property, config.shrinkingMode)456 config.listeners.forEach { it.beforeTest() }457 test(458 context,459 config,460 shrinkfn,461 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value),462 listOf(463 genA.classifier,464 genB.classifier,465 genC.classifier,466 genD.classifier,467 genE.classifier,468 genF.classifier,469 genG.classifier,470 genH.classifier471 ),472 random.seed473 ) {474 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value)475 }476 config.listeners.forEach { it.afterTest() }477 }478 context.outputClassifications(8, config, random.seed)479 context.checkMaxSuccess(config, random.seed)480 return context481}482suspend fun <A, B, C, D, E, F, G, H, I> proptest(483 genA: Gen<A>,484 genB: Gen<B>,485 genC: Gen<C>,486 genD: Gen<D>,487 genE: Gen<E>,488 genF: Gen<F>,489 genG: Gen<G>,490 genH: Gen<H>,491 genI: Gen<I>,492 config: PropTestConfig,493 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I) -> Unit494): PropertyContext {495 config.checkFailOnSeed()496 val constraints = config.constraints497 ?: config.iterations?.let { Constraints.iterations(it) }498 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)499 val context = PropertyContext()500 val random = createRandom(config)501 genA.generate(random, config.edgeConfig)502 .zip(genB.generate(random, config.edgeConfig))503 .zip(genC.generate(random, config.edgeConfig))504 .zip(genD.generate(random, config.edgeConfig))505 .zip(genE.generate(random, config.edgeConfig))506 .zip(genF.generate(random, config.edgeConfig))507 .zip(genG.generate(random, config.edgeConfig))508 .zip(genH.generate(random, config.edgeConfig))509 .zip(genI.generate(random, config.edgeConfig))510 .takeWhile { constraints.evaluate() }511 .forEach { (abcdefgh, i) ->512 val (abcdefg, h) = abcdefgh513 val (abcdef, g) = abcdefg514 val (abcde, f) = abcdef515 val (abcd, e) = abcde516 val (abc, d) = abcd517 val (ab, c) = abc518 val (a, b) = ab519 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, property, config.shrinkingMode)520 config.listeners.forEach { it.beforeTest() }521 test(522 context,523 config,524 shrinkfn,525 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value),526 listOf(527 genA.classifier,528 genB.classifier,529 genC.classifier,530 genD.classifier,531 genE.classifier,532 genF.classifier,533 genG.classifier,534 genH.classifier,535 genI.classifier536 ),537 random.seed538 ) {539 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value)540 }541 config.listeners.forEach { it.afterTest() }542 }543 context.outputClassifications(9, config, random.seed)544 context.checkMaxSuccess(config, random.seed)545 return context546}547suspend fun <A, B, C, D, E, F, G, H, I, J> proptest(548 genA: Gen<A>,549 genB: Gen<B>,550 genC: Gen<C>,551 genD: Gen<D>,552 genE: Gen<E>,553 genF: Gen<F>,554 genG: Gen<G>,555 genH: Gen<H>,556 genI: Gen<I>,557 genJ: Gen<J>,558 config: PropTestConfig,559 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J) -> Unit560): PropertyContext {561 config.checkFailOnSeed()562 val constraints = config.constraints563 ?: config.iterations?.let { Constraints.iterations(it) }564 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)565 val context = PropertyContext()566 val random = createRandom(config)567 genA.generate(random, config.edgeConfig)568 .zip(genB.generate(random, config.edgeConfig))569 .zip(genC.generate(random, config.edgeConfig))570 .zip(genD.generate(random, config.edgeConfig))571 .zip(genE.generate(random, config.edgeConfig))572 .zip(genF.generate(random, config.edgeConfig))573 .zip(genG.generate(random, config.edgeConfig))574 .zip(genH.generate(random, config.edgeConfig))575 .zip(genI.generate(random, config.edgeConfig))576 .zip(genJ.generate(random, config.edgeConfig))577 .takeWhile { constraints.evaluate() }578 .forEach { (abcdefghi, j) ->579 val (abcdefgh, i) = abcdefghi580 val (abcdefg, h) = abcdefgh581 val (abcdef, g) = abcdefg582 val (abcde, f) = abcdef583 val (abcd, e) = abcde584 val (abc, d) = abcd585 val (ab, c) = abc586 val (a, b) = ab587 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, j, property, config.shrinkingMode)588 config.listeners.forEach { it.beforeTest() }589 test(590 context,591 config,592 shrinkfn,593 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value),594 listOf(595 genA.classifier,596 genB.classifier,597 genC.classifier,598 genD.classifier,599 genE.classifier,600 genF.classifier,601 genG.classifier,602 genH.classifier,603 genI.classifier,604 genJ.classifier605 ),606 random.seed607 ) {608 context.property(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value)609 }610 config.listeners.forEach { it.afterTest() }611 }612 context.outputClassifications(10, config, random.seed)613 context.checkMaxSuccess(config, random.seed)614 return context615}616suspend fun <A, B, C, D, E, F, G, H, I, J, K> proptest(617 genA: Gen<A>,618 genB: Gen<B>,619 genC: Gen<C>,620 genD: Gen<D>,621 genE: Gen<E>,622 genF: Gen<F>,623 genG: Gen<G>,624 genH: Gen<H>,625 genI: Gen<I>,626 genJ: Gen<J>,627 genK: Gen<K>,628 config: PropTestConfig,629 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J, K) -> Unit630): PropertyContext {631 config.checkFailOnSeed()632 val constraints = config.constraints633 ?: config.iterations?.let { Constraints.iterations(it) }634 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)635 val context = PropertyContext()636 val random = createRandom(config)637 genA.generate(random, config.edgeConfig)638 .zip(genB.generate(random, config.edgeConfig))639 .zip(genC.generate(random, config.edgeConfig))640 .zip(genD.generate(random, config.edgeConfig))641 .zip(genE.generate(random, config.edgeConfig))642 .zip(genF.generate(random, config.edgeConfig))643 .zip(genG.generate(random, config.edgeConfig))644 .zip(genH.generate(random, config.edgeConfig))645 .zip(genI.generate(random, config.edgeConfig))646 .zip(genJ.generate(random, config.edgeConfig))647 .zip(genK.generate(random, config.edgeConfig))648 .takeWhile { constraints.evaluate() }649 .forEach { (abcdefghij, k) ->650 val (abcdefghi, j) = abcdefghij651 val (abcdefgh, i) = abcdefghi652 val (abcdefg, h) = abcdefgh653 val (abcdef, g) = abcdefg654 val (abcde, f) = abcdef655 val (abcd, e) = abcde656 val (abc, d) = abcd657 val (ab, c) = abc658 val (a, b) = ab659 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, j, k, property, config.shrinkingMode)660 config.listeners.forEach { it.beforeTest() }661 test(662 context,663 config,664 shrinkfn,665 listOf(a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value, i.value, j.value, k.value),666 listOf(667 genA.classifier,668 genB.classifier,669 genC.classifier,670 genD.classifier,671 genE.classifier,672 genF.classifier,673 genG.classifier,674 genH.classifier,675 genI.classifier,676 genJ.classifier,677 genK.classifier678 ),679 random.seed680 ) {681 context.property(682 a.value,683 b.value,684 c.value,685 d.value,686 e.value,687 f.value,688 g.value,689 h.value,690 i.value,691 j.value,692 k.value693 )694 }695 config.listeners.forEach { it.afterTest() }696 }697 context.outputClassifications(11, config, random.seed)698 context.checkMaxSuccess(config, random.seed)699 return context700}701suspend fun <A, B, C, D, E, F, G, H, I, J, K, L> proptest(702 genA: Gen<A>,703 genB: Gen<B>,704 genC: Gen<C>,705 genD: Gen<D>,706 genE: Gen<E>,707 genF: Gen<F>,708 genG: Gen<G>,709 genH: Gen<H>,710 genI: Gen<I>,711 genJ: Gen<J>,712 genK: Gen<K>,713 genL: Gen<L>,714 config: PropTestConfig,715 property: suspend PropertyContext.(A, B, C, D, E, F, G, H, I, J, K, L) -> Unit716): PropertyContext {717 config.checkFailOnSeed()718 val constraints = config.constraints719 ?: config.iterations?.let { Constraints.iterations(it) }720 ?: Constraints.iterations(PropertyTesting.defaultIterationCount)721 val context = PropertyContext()722 val random = createRandom(config)723 genA.generate(random, config.edgeConfig)724 .zip(genB.generate(random, config.edgeConfig))725 .zip(genC.generate(random, config.edgeConfig))726 .zip(genD.generate(random, config.edgeConfig))727 .zip(genE.generate(random, config.edgeConfig))728 .zip(genF.generate(random, config.edgeConfig))729 .zip(genG.generate(random, config.edgeConfig))730 .zip(genH.generate(random, config.edgeConfig))731 .zip(genI.generate(random, config.edgeConfig))732 .zip(genJ.generate(random, config.edgeConfig))733 .zip(genK.generate(random, config.edgeConfig))734 .zip(genL.generate(random, config.edgeConfig))735 .takeWhile { constraints.evaluate() }736 .forEach { (abcdefghijk, l) ->737 val (abcdefghij, k) = abcdefghijk738 val (abcdefghi, j) = abcdefghij739 val (abcdefgh, i) = abcdefghi740 val (abcdefg, h) = abcdefgh741 val (abcdef, g) = abcdefg742 val (abcde, f) = abcdef743 val (abcd, e) = abcde744 val (abc, d) = abcd745 val (ab, c) = abc746 val (a, b) = ab747 val shrinkfn = shrinkfn(a, b, c, d, e, f, g, h, i, j, k, l, property, config.shrinkingMode)748 config.listeners.forEach { it.beforeTest() }749 test(...

Full Screen

Full Screen

Constraints.kt

Source:Constraints.kt Github

copy

Full Screen

...4/**5 * Controls iterations of a property test.6 */7fun interface Constraints {8 fun evaluate(): Boolean9 companion object {10 /**11 * Returns a [Constraints] that executes the property test for a fixed number of iterations.12 */13 fun iterations(k: Int) = object : Constraints {14 var count = 015 override fun evaluate(): Boolean {16 val result = count < k17 count++18 return result19 }20 }21 /**22 * Returns a [Constraints] that executes the property test for a certain duration.23 */24 fun duration(duration: Duration) = object : Constraints {25 val mark = TimeSource.Monotonic.markNow().plus(duration)26 override fun evaluate(): Boolean {27 return mark.hasNotPassedNow()28 }29 }30 }31}32fun Constraints.and(other: Constraints) = Constraints { this@and.evaluate() && other.evaluate() }33fun Constraints.or(other: Constraints) = Constraints { this@or.evaluate() || other.evaluate() }...

Full Screen

Full Screen

evaluate

Using AI Code Generation

copy

Full Screen

1val constraints = Constraints(maxSuccess = 1000)2val result = constraints.evaluate {3val a = Gen.int().random().first()4val b = Gen.int().random().first()5a + b shouldBe (a + b)6}7println(result)8val constraints = Constraints(maxSuccess = 1000)9val result = constraints.evaluate {10val a = Gen.int().random().first()11val b = Gen.int().random().first()12a + b shouldBe (a + b)13}14println(result)15val constraints = Constraints(maxSuccess = 1000)16val result = constraints.evaluate {17val a = Gen.int().random().first()18val b = Gen.int().random().first()19a + b shouldBe (a + b)20}21println(result)22println(result.passes)23println(result.isSuccess)24println(result.errorCount)25println(result.failureCount)26TestResult(passes=true, isSuccess=true, errorCount=0, failureCount=0)27val constraints = Constraints(maxSuccess = 1000)28val result = constraints.evaluate {

Full Screen

Full Screen

evaluate

Using AI Code Generation

copy

Full Screen

1val x = Gen.int().random(this).first()2val y = Gen.int().random(this).first()3x + y shouldBe (y + x)4}5val x = Gen.int().random(this).first()6val y = Gen.int().random(this).first()7x + y shouldBe (y + x)8}9val x = Gen.int().random(this).first()10val y = Gen.int().random(this).first()11x + y shouldBe (y + x)12}13val x = Gen.int().random(this).first()14val y = Gen.int().random(this).first()15x + y shouldBe (y + x)16}17val x = Gen.int().random(this).first()18val y = Gen.int().random(this).first()19x + y shouldBe (y + x)20}21val x = Gen.int().random(this).first()22val y = Gen.int().random(this).first()23x + y shouldBe (y + x)24}25val x = Gen.int().random(this).first()26val y = Gen.int().random(this).first()27x + y shouldBe (y

Full Screen

Full Screen

evaluate

Using AI Code Generation

copy

Full Screen

1val constraints = Constraints(1000, 10000)2val result = constraints.evaluate {3 val random = Random.nextDouble()4 if(random < 0.1) {5 throw IllegalArgumentException("random number $random is too small")6 }7 if(random > 0.9) {8 throw IllegalArgumentException("random number $random is too large")9 }10}11result shouldBe passed()12result shouldBe failed()13result shouldBe failed<IllegalArgumentException>()14result shouldBe failed<IllegalArgumentException>("random number 0.0 is too small")15result shouldBe failed<IllegalArgumentException>("random number 0.0 is too small")16result shouldBe failed<IllegalArgumentException> { it.message == "random number 0.0 is too small" }17data class Person(val name: String, val age: Int)18val people = table(19 headers("name", "age"),20 row("sam", 30),21 row("jane", 40),22 row("joe", 50)23forAll(people) { name, age ->24 Person(name, age).name shouldBe name25}26val people = table(csv("name,age"), csv("sam,30"), csv("jane,40"), csv("joe,50"))27forAll(people) { name, age ->28 Person(name, age).name shouldBe name29}

Full Screen

Full Screen

evaluate

Using AI Code Generation

copy

Full Screen

1property("String should have at least 3 characters") {2forAll<String> { s ->3}4}5}6fun testStringShouldHaveAtLeast3Chars() {7val config = PropertyTestingConfig(iterations = 10, threads = 1)8property("String should have at least 3 characters") {9forAll<String> { s ->10}11}12}13io.kotest.property.PropertyAssertionError: Property failed for 1 inputs (10 shrinks) after 10 attempts

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful