https://github.com/ubiratansoares/tite
A Kotlin DSL for gorgeous RxJava2 tests
https://github.com/ubiratansoares/tite
kotlin kotlin-dsl kotlin-library rxjava2 testing-library testing-tools
Last synced: 3 months ago
JSON representation
A Kotlin DSL for gorgeous RxJava2 tests
- Host: GitHub
- URL: https://github.com/ubiratansoares/tite
- Owner: ubiratansoares
- License: mit
- Created: 2018-08-02T05:00:55.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-30T05:57:23.000Z (over 6 years ago)
- Last Synced: 2025-04-13T13:55:33.541Z (3 months ago)
- Topics: kotlin, kotlin-dsl, kotlin-library, rxjava2, testing-library, testing-tools
- Language: Kotlin
- Size: 608 KB
- Stars: 18
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# TITE
> A Kotlin DSL for gorgeous RxJava2 tests
[](https://circleci.com/gh/ubiratansoares/tite/tree/master)
 [](https://jitpack.io/#ubiratansoares/tite)Tite is a simple DSL on top of existing RxJava2 testing APIs. This DSL proposes a nice way to perform assertions, while leveraging 100% on existing testing machinery of current RxJava.
## Overview
Powered by Tite, tests for your RxJava-based APIs will look like this
```kotlin
val words = Observable.just("Adenor", "Leonardo", "Bacchi")
given(words) {
beforeChecksAwait {
countingTime until 3.seconds
}assertThatSequence {
should be completed
should be terminated
should notBe broken
should be subscribed
}verifyForEmissions {
items match sequenceOf("Adenor", "Leonardo", "Bacchi")
firstItem shouldBe "Adenor"
never emmits "Parreira"
never emmits "Felipão"
}
verifyWhenError {
fails byError NumberFormatException
fails withErrorMessage "exception msg"
fails byType FileAlreadyExistsException::class
fails byMatching { it -> it == CredentialsAccessError }
}
}```
instead of this
```kotlin
val words = Observable.just("Adenor", "Leonardo", "Bacchi")
words.test()
.assertComplete()
.assertTerminated()
.assertNoErrors()
.assertValueSequence(listOf("Adenor", "Leonardo", "Bacchi"))
// ... more verifications
```Don't get me wrong here : fluent, chainable API style is quite great for Java ... but we can do better with Kotlin!
## Quick Setup
Grab this dependency to your Gradle project using [Jitpack](https://jitpack.io)
For Android projects
```groovy
dependencies {
implementation 'com.github.ubiratansoares:tite:'
}
```For non-Android Gradle projects
```
dependencies {
compile 'com.github.ubiratansoares:tite:'
}
```Current version of this library (`0.1.1`) matches
- Kotlin `1.3.11`
- RxJava `2.2.4`## Documentation
You can check the full API documentation, including samples for DSL grammar [here](https://ubiratansoares.github.io/tite).
You may want to check the latests [releases](https://github.com/ubiratan/tite/releases) for this project as well.
## Contributing
1. Fork this repository
2. Create your branch
3. Code your contributions
4. Open a PR !!! 🚀## About
`Adenor Leonardo Bacchi`, a.k.a Tite, is a physical education professional, teacher, and legendary soccer team coach.
He was Brazil team's coach at FIFA's World Cup (Russia / 2018), as well the main leader behind the greatests achievements of Sport Club Corinthians Paulista - the greatest soccer team in Brazil - in the last decade. ⚽
## License
```
The MIT License (MIT)Copyright (c) 2018 Ubiratan Soares
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```