Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/toolisticon/jgiven-kotlin
Extensions to make working with jgiven.org and Kotlin even more fun
https://github.com/toolisticon/jgiven-kotlin
bdd jgiven kotlin testing
Last synced: 2 months ago
JSON representation
Extensions to make working with jgiven.org and Kotlin even more fun
- Host: GitHub
- URL: https://github.com/toolisticon/jgiven-kotlin
- Owner: toolisticon
- License: apache-2.0
- Created: 2021-01-27T15:42:26.000Z (almost 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-10-16T09:41:48.000Z (2 months ago)
- Last Synced: 2024-10-18T05:46:30.955Z (2 months ago)
- Topics: bdd, jgiven, kotlin, testing
- Language: Kotlin
- Homepage:
- Size: 306 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jgiven-kotlin
Extensions that make working with the JVM BDD testing tool [jgiven](https://jgiven.org) and Kotlin even more fun.
[![stable](https://img.shields.io/badge/lifecycle-STABLE-green.svg)](https://github.com/toolisticon#stable)
[![Build Status](https://github.com/toolisticon/jgiven-kotlin/workflows/Development%20branches/badge.svg)](https://github.com/toolisticon/jgiven-kotlin/actions)
[![sponsored](https://img.shields.io/badge/sponsoredBy-Holisticon-red.svg)](https://holisticon.de/)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.testing/jgiven-kotlin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.toolisticon.testing/jgiven-kotlin)
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftoolisticon%2Fjgiven-kotlin.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftoolisticon%2Fjgiven-kotlin?ref=badge_shield)## Usage
### Maven
```io.toolisticon.testing
jgiven-kotlin
1.3.0.0
test```
## Features
### GIVEN,WHEN,THEN
when using kotlin, instead of
```
given()
.some_facts()`when`() // when is a keyword in kotlin
.something_happens()then()
.expect_a_result()```
you can simply use the dynamic extension properties:
```kotlin
GIVEN
.some_facts();WHEN
.something_happens()THEN
.expect_a_result()
```(written in CAPS to avoid keyword conflicts).
### Implementing Stages
In jgiven-java, you have to do:
```java
class MyStage extends Stage {MyStage my_step() {
// what the step does
return self();
}
}
```jgiven-kotlin introduces the inline extension function `step()`, so this can be simplified to:
```kotlin
@JGivenKotlinStage
class MyStage : Stage() {fun `my step`() = step {
// what the step does
}
}
```### JGivenKotlinStage annotation
Since all classes and functions are final by default in kotlin, you have to explicitly mark everything you write in a Stage to be `open`.
Using the `JGivenKotlinStage` annotation and kotlin's "all-open" compiler plugin, this can be avoided.
#### Gradle
```kotlin
plugins {
id("org.jetbrains.kotlin.plugin.allopen") version "${kotlin_version}"
}//...
allOpen {
annotation("io.toolisticon.testing.jgiven.JGivenKotlinStage")
}
```#### Maven
```xml
kotlin-maven-plugin
org.jetbrains.kotlin
all-open
all-open:annotation=io.toolisticon.testing.jgiven.JGivenKotlinStage
org.jetbrains.kotlin
kotlin-maven-allopen
${kotlin.version}
```
## Notes
* These helpers where moved from [jgiven-addons](https://github.com/toolisticon/jgiven-addons) for better separation of concerns and
simplified publishing.
* This extension might become obsolete once jgiven [supports this officially](https://github.com/TNG/JGiven/pull/407).## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Ftoolisticon%2Fjgiven-kotlin.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Ftoolisticon%2Fjgiven-kotlin?ref=badge_large)