Skip to content

Commit

Permalink
prepare release v0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
evant committed Dec 5, 2023
1 parent c9209ca commit 2777987
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ 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.28.0] 2023-12-05

### Changed
- Minimum supported kotlin version is 1.9.21
Expand Down
60 changes: 34 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,47 @@ assertk is a fluent assertion library for Kotlin inspired by [AssertJ](https://g

## Why another assertion library?

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.
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.

See [Custom Assertions](#custom-assertions) below to find out how to do this.

## Setup

```kotlin
repositories {
mavenCentral()
mavenCentral()
}

dependencies {
testImplementation("com.willowtreeapps.assertk:assertk:0.27.0")
testImplementation("com.willowtreeapps.assertk:assertk:0.28.0")
}
```

assertk has full multiplatform support and it can be used in jvm, js, or native projects. For example to set it up using
the multiplatform plugin:

```kotlin
plugins {
kotlin("multiplatform")
kotlin("multiplatform")
}

kotlin {
sourceSets {
val commonTest by getting {
dependencies {
implementation("com.willowtreeapps.assertk:assertk:0.27.0")
}
sourceSets {
val commonTest by getting {
dependencies {
implementation("com.willowtreeapps.assertk:assertk:0.28.0")
}
}
}
}
}
```

## Usage

Simple usage is to wrap the value or property you are testing in `assertThat()` and call assertion methods on the result.
Simple usage is to wrap the value or property you are testing in `assertThat()` and call assertion methods on the
result.

```kotlin
import assertk.assertThat
Expand Down Expand Up @@ -75,9 +79,11 @@ class PersonTest {
}
```

You can see all built-in assertions in the [docs](https://willowtreeapps.github.io/assertk/assertk/assertk.assertions/index.html).
You can see all built-in assertions in
the [docs](https://willowtreeapps.github.io/assertk/assertk/assertk.assertions/index.html).

### Nullability

Since null is a first-class concept in kotlin's type system, you need to be explicit in your assertions.

```kotlin
Expand Down Expand Up @@ -128,14 +134,14 @@ assertAll {
You can assert on the contents of an `Iterable/List` with the various `contains*` functions. They have different
semantics as follows:

|Assertion|Description|
|---|---|
|containsAll|Asserts the iterable contains all the expected elements, in **any order**. The collection may also contain **additional elements**.|
|containsSubList|Asserts that a collection contains a **subset** of items the **same order**, but may have **additional elements** in the list.|
|containsOnly|Asserts the iterable contains **only the expected elements**, in **any order**. **Duplicate values** in the expected and actual are ignored.|
|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.|
|containsExactly|Asserts the list contains **exactly the expected elements**. They must be in the **same order** and there must not be any extra elements.|
|containsNone|Asserts the iterable **does not contain any** of the expected elements|
| Assertion | Description |
|---------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| containsAtLeast | Asserts the iterable contains at least the expected elements, in **any order**. The collection may also contain **additional elements**. |
| containsSubList | Asserts that a collection contains a **subset** of items the **same order**, but may have **additional elements** in the list. |
| containsOnly | Asserts the iterable contains **only the expected elements**, in **any order**. **Duplicate values** in the expected and actual are ignored. |
| 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. |
| containsExactly | Asserts the list contains **exactly the expected elements**. They must be in the **same order** and there must not be any extra elements. |
| containsNone | Asserts the iterable **does not contain any** of the expected elements |

### Extracting data

Expand Down Expand Up @@ -236,11 +242,11 @@ return something more specific that additional assertions can be chained on.

```kotlin
fun Assert<Person>.hasMiddleName(): Assert<String> = transform(appendName("middleName", separator = ".")) { actual ->
if (actual.middleName != null) {
actual.middleName
} else {
expected("to not be null")
}
if (actual.middleName != null) {
actual.middleName
} else {
expected("to not be null")
}
}

assertThat(person).hasMiddleName().isEqualTo("Lorie")
Expand All @@ -263,4 +269,6 @@ error message.

## Contributing to assertk

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).
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).
4 changes: 2 additions & 2 deletions assertk-coroutines/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ repositories {
}
dependencies {
testCompile 'com.willowtreeapps.assertk:assertk-coroutines:0.23'
testCompile("com.willowtreeapps.assertk:assertk-coroutines:0.28.0")
}
```

## Usage

### Flow

Currently, the main thing this lib provides is many of the collection assertions on `Flow`. For example you can do
Currently, the main thing this lib provides is many of the collection assertions on `Flow`. For example, you can do

```kotlin
runBlocking {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
assertk = "0.28.0-SNAPSHOT"
assertk = "0.28.0"
kotlin = "1.9.21"
kotlinx-coroutines = "1.7.3"
[libraries]
Expand Down

0 comments on commit 2777987

Please sign in to comment.