You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-26Lines changed: 34 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,43 +10,47 @@ assertk is a fluent assertion library for Kotlin inspired by [AssertJ](https://g
10
10
11
11
## Why another assertion library?
12
12
13
-
You might be asking, "If AssertJ already exists, why create another library?". It's true, assertk is very similar to AssertJ. But assertk is written in Kotlin so it has one major advantage: extension methods. This makes adding your own assertion methods far simpler.
13
+
You might be asking, "If AssertJ already exists, why create another library?". It's true, assertk is very similar to
14
+
AssertJ. But assertk is written in Kotlin so it has one major advantage: extension methods. This makes adding your own
15
+
assertion methods far simpler.
14
16
15
17
See [Custom Assertions](#custom-assertions) below to find out how to do this.
Simple usage is to wrap the value or property you are testing in `assertThat()` and call assertion methods on the result.
52
+
Simple usage is to wrap the value or property you are testing in `assertThat()` and call assertion methods on the
53
+
result.
50
54
51
55
```kotlin
52
56
importassertk.assertThat
@@ -75,9 +79,11 @@ class PersonTest {
75
79
}
76
80
```
77
81
78
-
You can see all built-in assertions in the [docs](https://willowtreeapps.github.io/assertk/assertk/assertk.assertions/index.html).
82
+
You can see all built-in assertions in
83
+
the [docs](https://willowtreeapps.github.io/assertk/assertk/assertk.assertions/index.html).
79
84
80
85
### Nullability
86
+
81
87
Since null is a first-class concept in kotlin's type system, you need to be explicit in your assertions.
82
88
83
89
```kotlin
@@ -128,14 +134,14 @@ assertAll {
128
134
You can assert on the contents of an `Iterable/List` with the various `contains*` functions. They have different
129
135
semantics as follows:
130
136
131
-
|Assertion|Description|
132
-
|---|---|
133
-
|containsAll|Asserts the iterable contains all the expected elements, in **any order**. The collection may also contain **additional elements**.|
134
-
|containsSubList|Asserts that a collection contains a **subset** of items the **same order**, but may have **additional elements** in the list.|
135
-
|containsOnly|Asserts the iterable contains **only the expected elements**, in **any order**. **Duplicate values** in the expected and actual are ignored.|
136
-
|containsExactlyInAnyOrder|Asserts the iterable contains **exactly the expected elements**, in **any order**. Each value in expected must correspond to a matching value in actual, and visa-versa.|
137
-
|containsExactly|Asserts the list contains **exactly the expected elements**. They must be in the **same order** and there must not be any extra elements.|
138
-
|containsNone|Asserts the iterable **does not contain any** of the expected elements|
| containsAtLeast |Asserts the iterable contains at least the expected elements, in **any order**. The collection may also contain **additional elements**.|
140
+
|containsSubList|Asserts that a collection contains a **subset** of items the **same order**, but may have **additional elements** in the list.|
141
+
|containsOnly|Asserts the iterable contains **only the expected elements**, in **any order**. **Duplicate values** in the expected and actual are ignored.|
142
+
|containsExactlyInAnyOrder|Asserts the iterable contains **exactly the expected elements**, in **any order**. Each value in expected must correspond to a matching value in actual, and visa-versa.|
143
+
|containsExactly|Asserts the list contains **exactly the expected elements**. They must be in the **same order** and there must not be any extra elements.|
144
+
|containsNone|Asserts the iterable **does not contain any** of the expected elements|
139
145
140
146
### Extracting data
141
147
@@ -236,11 +242,11 @@ return something more specific that additional assertions can be chained on.
236
242
237
243
```kotlin
238
244
fun Assert<Person>.hasMiddleName(): Assert<String> = transform(appendName("middleName", separator =".")) { actual ->
Contributions are more than welcome! Please see the [Contributing Guidelines](https://github.com/willowtreeapps/assertk/blob/main/Contributing.md) and be mindful of our [Code of Conduct](https://github.com/willowtreeapps/assertk/blob/main/code-of-conduct.md).
272
+
Contributions are more than welcome! Please see
273
+
the [Contributing Guidelines](https://github.com/willowtreeapps/assertk/blob/main/Contributing.md) and be mindful of
274
+
our [Code of Conduct](https://github.com/willowtreeapps/assertk/blob/main/code-of-conduct.md).
0 commit comments