Skip to content

Commit 36028b8

Browse files
committed
update readme
1 parent 9728008 commit 36028b8

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,28 @@
44
# AssertK - Fluent assertions for Kotlin
55
AssertK provides a Kotlin-friendly syntax for using the amazing AssertJ assertion framework.
66

7-
This is early stages work and the library is not yet complete. Only a small subset of the AssertJ-core features are already implemented, but those that are, should be ready to be used in your projects. Contributions are welcome with regards to adding functionality to match that of AssertJ.
8-
97
###Simple assertions
108
```kotlin
119
assert that Unit isEqualTo Unit
12-
assert that Any() isNotEqualTo Any()
13-
assert that Any() _is notNull
14-
assert that nullObject _is null
15-
assert that anObject isInstance of<Any>()
16-
assert that Any() describedAs "A labeled object" isInstance of<Unit>()
10+
```
11+
12+
you can use `assert that` or `expect that` interchangeably as `assert` tends to be a bit noisy given when relying on autocomplete.
13+
```kotlin
14+
expect that Any() isNotEqualTo Any()
15+
expect that Any() _is notNull
16+
expect that nullObject _is null
17+
expect that anObject isInstance of<Any>()
18+
expect that Any() describedAs "A labeled object" isInstance of<Unit>()
1719
```
1820

1921
###Chained syntax
2022
```kotlin
21-
assert that Unit isNotEqualTo Any() isEqualTo Unit _is notNull isInstance of<Any>()
23+
expect that Unit isNotEqualTo Any() isEqualTo Unit _is notNull isInstance of<Any>()
2224
```
2325

2426
###Block syntax
2527
```kotlin
26-
assert that Any() isSuchThat {
28+
expect that Any() isSuchThat {
2729
it _is notNull
2830
it isInstance of<Any>()
2931
it isNotEqualTo Unit
@@ -34,12 +36,12 @@ assert that Any() isSuchThat {
3436
##Assertions on exceptions
3537
###Chained syntax
3638
```kotlin
37-
assert thatExceptionIsThrownBy { failFunction() } hasMessageContaining "foo" hasCause Throwable()
39+
expect thatExceptionIsThrownBy { failFunction() } hasMessageContaining "foo" hasCause Throwable()
3840
```
3941

4042
###Block syntax
4143
```kotlin
42-
assert thatExceptionIsThrownBy {
44+
expect thatExceptionIsThrownBy {
4345
throw Throwable("exception foo", Throwable())
4446
} and {
4547
it hasMessage "exception foo"
@@ -51,6 +53,20 @@ assert thatExceptionIsThrownBy {
5153
}
5254
```
5355

56+
#Further Examples
57+
##Iterable Assert
58+
```kotlin
59+
expect that myListOfInts hasSize 10 contains 3 startsWith 1
60+
```
61+
##Boolean Assert
62+
```kotlin
63+
expect that myBoolean _is false
64+
```
65+
##Float, Double, Int, Long Assert
66+
```kotlin
67+
expect that myFloat isGreaterThan otherFloat
68+
expect that myInt _is notPositive isLessThan expectedResult
69+
```
5470
##Get it
5571
```groovy
5672
allprojects {
@@ -61,7 +77,7 @@ allprojects {
6177
}
6278
dependencies {
6379
...
64-
testCompile 'com.github.memoizr:assertk-core:0.0.2-Alpha'
80+
testCompile 'com.github.memoizr:assertk-core:0.1.0'
6581
...
6682
}
6783
```

0 commit comments

Comments
 (0)