Skip to content

Commit

Permalink
Prepare release 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
evant committed Jul 13, 2019
1 parent 93924a2 commit f48c768
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 29 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.18] 2019-07-12

### Added
- Add `extracting` to allow extracing a value for each item in an array.
- Add `Assert<Result<T>>.isSuccess()` and `Assert<Result<T>>.isFailure()` to replace `AssertBlock` assertions.
- Add `messageContains` for throwable.

### Changed
- Minimum supported kotlin version is 1.3.40
Expand Down
31 changes: 5 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories {
}
dependencies {
testCompile 'com.willowtreeapps.assertk:assertk-jvm:0.17'
testCompile 'com.willowtreeapps.assertk:assertk-jvm:0.18'
}
```

Expand Down Expand Up @@ -104,42 +104,21 @@ assertAll {

### Exceptions

If you expect an exception to be thrown, you have a couple of options:

The first is to wrap in a `catch` block to store the result, then assert on that.

```kotlin
val exception = catch { throw Exception("error") }
assertThat(exception).isNotNull().hasMessage("wrong")
// -> expected [message] to be:<["wrong"]> but was:<["error"]>
```

Your other option is to use an `assertThat` with a single lambda arg to capture the error.
If you expect an exception to be thrown, you can use the version of `assertThat` that takes a lambda.

```kotlin
assertThat {
throw Exception("error")
}.thrownError {
hasMessage("wrong")
}
}.isFailure().hasMessage("wrong")
// -> expected [message] to be:<["wrong"]> but was:<["error"]>
```

This method also allows you to assert on return values.
This method also allows you to assert on successfully returned values.
```kotlin
assertThat { 1 + 1 }.returnedValue {
isNegative()
}
assertThat { 1 + 1 }.isSucess().isNegative()
// -> expected to be negative but was:<2>
```

You can also assert that there no exceptions thrown
```kotlin
assertThat {
aMethodThatMightThrow()
}.doesNotThrowAnyException()
```

### Table Assertions

If you have multiple sets of values you want to test with, you can create a table assertion.
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

allprojects {
group 'com.willowtreeapps.assertk'
version '0.18-SNAPSHOT'
version '0.18'
}

ext {
Expand Down Expand Up @@ -75,7 +75,7 @@ kotlin {
}
}

def opentest4k_version = '1.1.3-SNAPSHOT'
def opentest4k_version = '1.1.3'
def kotlin_coroutines_version = '1.2.2'

sourceSets {
Expand Down

0 comments on commit f48c768

Please sign in to comment.