Skip to content

Commit 126c4d8

Browse files
authored
Update Kotest dependency to latest (#44)
1 parent 5f2f768 commit 126c4d8

File tree

21 files changed

+665
-923
lines changed

21 files changed

+665
-923
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Include the following dependencies in your `build.gradle.kts` file:
1212
```kotlin
1313
testImplementation("com.appmattus.fixture:fixture:<latest-version>")
1414

15-
// Add for KotlinTest integration
16-
testImplementation("com.appmattus.fixture:fixture-kotlintest:<latest-version>")
15+
// Add for Kotest integration
16+
testImplementation("com.appmattus.fixture:fixture-kotest:<latest-version>")
1717
```
1818

1919
Simply create a fixture and invoke it with the type to be generated:
@@ -392,24 +392,25 @@ ktype kotlin.String →
392392
Success(5878ec34-c30f-40c7-ad52-c15a39b44ac1)
393393
```
394394

395-
## KotlinTest support
395+
## Kotest support
396396

397-
[KotlinTest](https://github.com/kotlintest/kotlintest/) supports
398-
[property testing](https://github.com/kotlintest/kotlintest/blob/master/doc/reference.md#property-based),
399-
but to use it with more than just the few basic types that are built into the
400-
library requires you to create your own custom generators that you then have to
401-
provide.
397+
[Kotest](https://github.com/kotest/kotest/) supports
398+
[property testing](https://github.com/kotest/kotest/blob/master/doc/reference.md#property-based-testing-),
399+
but to use it with more than just the few basic types that are built
400+
into the library requires you to create your own custom generators that
401+
you then have to provide.
402402

403-
Including the `fixture-kotlintest` dependency in your project adds extension
404-
functions `assertAll`, `assertNone`, `forAll` and `forNone` to the fixture.
405-
These functions wrap the equivalent functions from KotlinTest while providing
406-
generation of all the classes [KotlinFixture](https://github.com/appmattus/kotlinfixture)
407-
supports. For example:
403+
Including the `fixture-kotest` dependency in your project adds extension
404+
functions `checkAll` and `forAll` to the fixture. These
405+
functions wrap the equivalent functions from Kotest while providing
406+
generation of all the classes
407+
[KotlinFixture](https://github.com/appmattus/kotlinfixture) supports.
408+
For example:
408409

409410
```kotlin
410411
data class Person(name: String, age: Int)
411412

412-
fixture.assertAll { person1: Person, person2: Person ->
413+
fixture.checkAll { person1: Person, person2: Person ->
413414
person1 shouldNotBeSameInstanceAs person2
414415
}
415416
```

bintray.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ buildscript {
2222
jcenter()
2323
}
2424
dependencies {
25-
classpath("com.novoda:bintray-release:0.9.1")
25+
classpath("com.novoda:bintray-release:0.9.2")
2626
}
2727
}
2828

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
1919

2020
plugins {
2121
id("com.github.ben-manes.versions") version "0.28.0"
22-
id("io.gitlab.arturbosch.detekt") version "1.8.0"
22+
id("io.gitlab.arturbosch.detekt") version "1.9.0"
2323
id("com.appmattus.markdown") version "0.6.0"
2424
}
2525

@@ -67,7 +67,7 @@ tasks.withType(DependencyUpdatesTask::class.java).all {
6767
}
6868

6969
dependencies {
70-
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.8.0")
70+
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.9.0")
7171
}
7272

7373
detekt {

fixture-kotest/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# fixture-kotest module
2+
3+
This module provides integration with
4+
[Kotest](https://github.com/kotest/kotest/), see the main
5+
[readme](../README.md#kotest-support) for further details.

fixture-kotlintest/build.gradle.kts renamed to fixture-kotest/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ apply(from = "$rootDir/gradle/scripts/jacoco.gradle.kts")
2727
dependencies {
2828
api(kotlin("stdlib-jdk8"))
2929
api(project(":fixture"))
30-
api("io.kotlintest:kotlintest-runner-junit5:3.4.2")
30+
api("io.kotest:kotest-property-jvm:4.0.5")
3131

3232
testImplementation("junit:junit:4.13")
3333
testImplementation(kotlin("test"))
3434
testImplementation(kotlin("test-junit"))
3535
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
3636

3737
testImplementation(kotlin("reflect"))
38+
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.6")
3839
}
3940

4041
lintOptions {
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
/*
2+
* Copyright 2020 Appmattus Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
@file:Suppress("TooManyFunctions")
18+
19+
package com.appmattus.kotlinfixture.kotest
20+
21+
import com.appmattus.kotlinfixture.Fixture
22+
import io.kotest.property.PropTestConfig
23+
import io.kotest.property.PropertyContext
24+
import io.kotest.property.checkAll
25+
26+
// 1 parameter
27+
28+
suspend inline fun <reified A> Fixture.checkAll(
29+
noinline fn: suspend PropertyContext.(a: A) -> Unit
30+
) = checkAll(kotestGen(), fn)
31+
32+
suspend inline fun <reified A> Fixture.checkAll(
33+
iterations: Int,
34+
noinline fn: suspend PropertyContext.(a: A) -> Unit
35+
) = checkAll(iterations, kotestGen(), fn)
36+
37+
suspend inline fun <reified A> Fixture.checkAll(
38+
config: PropTestConfig,
39+
noinline fn: suspend PropertyContext.(a: A) -> Unit
40+
) = checkAll(config, kotestGen(), fn)
41+
42+
suspend inline fun <reified A> Fixture.checkAll(
43+
iterations: Int,
44+
config: PropTestConfig,
45+
noinline fn: suspend PropertyContext.(a: A) -> Unit
46+
) = checkAll(iterations, config, kotestGen(), fn)
47+
48+
// 2 parameters
49+
50+
suspend inline fun <reified A, reified B> Fixture.checkAll(
51+
noinline fn: suspend PropertyContext.(a: A, b: B) -> Unit
52+
) = checkAll(kotestGen(), kotestGen(), fn)
53+
54+
suspend inline fun <reified A, reified B> Fixture.checkAll(
55+
iterations: Int,
56+
noinline fn: suspend PropertyContext.(a: A, b: B) -> Unit
57+
) = checkAll(iterations, kotestGen(), kotestGen(), fn)
58+
59+
suspend inline fun <reified A, reified B> Fixture.checkAll(
60+
config: PropTestConfig,
61+
noinline fn: suspend PropertyContext.(a: A, b: B) -> Unit
62+
) = checkAll(config, kotestGen(), kotestGen(), fn)
63+
64+
suspend inline fun <reified A, reified B> Fixture.checkAll(
65+
iterations: Int,
66+
config: PropTestConfig,
67+
noinline fn: suspend PropertyContext.(a: A, b: B) -> Unit
68+
) = checkAll(iterations, config, kotestGen(), kotestGen(), fn)
69+
70+
// 3 parameters
71+
72+
suspend inline fun <reified A, reified B, reified C> Fixture.checkAll(
73+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C) -> Unit
74+
) = checkAll(kotestGen(), kotestGen(), kotestGen(), fn)
75+
76+
suspend inline fun <reified A, reified B, reified C> Fixture.checkAll(
77+
iterations: Int,
78+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C) -> Unit
79+
) = checkAll(iterations, kotestGen(), kotestGen(), kotestGen(), fn)
80+
81+
suspend inline fun <reified A, reified B, reified C> Fixture.checkAll(
82+
config: PropTestConfig,
83+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C) -> Unit
84+
) = checkAll(config, kotestGen(), kotestGen(), kotestGen(), fn)
85+
86+
suspend inline fun <reified A, reified B, reified C> Fixture.checkAll(
87+
iterations: Int,
88+
config: PropTestConfig,
89+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C) -> Unit
90+
) = checkAll(iterations, config, kotestGen(), kotestGen(), kotestGen(), fn)
91+
92+
// 4 parameters
93+
94+
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.checkAll(
95+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Unit
96+
) = checkAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
97+
98+
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.checkAll(
99+
iterations: Int,
100+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Unit
101+
) = checkAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
102+
103+
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.checkAll(
104+
config: PropTestConfig,
105+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Unit
106+
) = checkAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
107+
108+
suspend inline fun <reified A, reified B, reified C, reified D> Fixture.checkAll(
109+
iterations: Int,
110+
config: PropTestConfig,
111+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D) -> Unit
112+
) = checkAll(iterations, config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
113+
114+
// 5 parameters
115+
116+
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.checkAll(
117+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Unit
118+
) = checkAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
119+
120+
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.checkAll(
121+
iterations: Int,
122+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Unit
123+
) = checkAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
124+
125+
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.checkAll(
126+
config: PropTestConfig,
127+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Unit
128+
) = checkAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
129+
130+
suspend inline fun <reified A, reified B, reified C, reified D, reified E> Fixture.checkAll(
131+
iterations: Int,
132+
config: PropTestConfig,
133+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E) -> Unit
134+
) = checkAll(iterations, config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
135+
136+
// 6 parameters
137+
138+
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.checkAll(
139+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Unit
140+
) = checkAll(kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
141+
142+
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.checkAll(
143+
iterations: Int,
144+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Unit
145+
) = checkAll(iterations, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
146+
147+
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.checkAll(
148+
config: PropTestConfig,
149+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Unit
150+
) = checkAll(config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)
151+
152+
suspend inline fun <reified A, reified B, reified C, reified D, reified E, reified F> Fixture.checkAll(
153+
iterations: Int,
154+
config: PropTestConfig,
155+
noinline fn: suspend PropertyContext.(a: A, b: B, c: C, d: D, e: E, f: F) -> Unit
156+
) = checkAll(iterations, config, kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), kotestGen(), fn)

0 commit comments

Comments
 (0)