Skip to content

Commit 8e7eef4

Browse files
committed
merge upstream
2 parents 36028b8 + 505a61f commit 8e7eef4

File tree

6 files changed

+64
-12
lines changed

6 files changed

+64
-12
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ language: java
22
jdk:
33
- oraclejdk8
44
after_success:
5-
- ./gradlew cobertura coveralls
5+
- if [ -e ./gradlew ]; then ./gradlew jacocoTestReport;else gradle jacocoTestReport;fi
6+
- bash <(curl -s https://codecov.io/bash) -t 7a683107-98e4-4c0d-b154-649e9ac9693c

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
[![Build Status](https://travis-ci.org/memoizr/assertk-core.svg?branch=master)](https://travis-ci.org/memoizr/assertk-core)
2-
[![](https://jitpack.io/v/memoizr/assertk-core.svg)](https://jitpack.io/#memoizr/assertk-core)
3-
[![GitHub license](https://img.shields.io/github/license/kotlintest/kotlintest.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)
1+
[![Build Status](https://travis-ci.org/memoizr/assertk-core.svg?branch=master)](https://travis-ci.org/memoizr/assertk-core) [![](https://jitpack.io/v/memoizr/assertk-core.svg)](https://jitpack.io/#memoizr/assertk-core) [![GitHub license](https://img.shields.io/github/license/kotlintest/kotlintest.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) [![codecov](https://codecov.io/gh/memoizr/assertk-core/branch/master/graph/badge.svg)](https://codecov.io/gh/memoizr/assertk-core)
2+
43
# AssertK - Fluent assertions for Kotlin
54
AssertK provides a Kotlin-friendly syntax for using the amazing AssertJ assertion framework.
65

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@ buildscript {
1111
}
1212
}
1313

14-
plugins {
15-
id 'net.saliman.cobertura' version '2.3.1'
16-
id 'com.github.kt3k.coveralls' version '2.6.3'
17-
}
18-
19-
cobertura.coverageFormats = ['html', 'xml']
20-
cobertura.coverageSourceDirs = ['src/main/kotlin']
21-
cobertura.coverageSourceDirs = ['src/test/kotlin']
2214
group 'com.memoizr'
2315
version '0.1'
2416

2517
apply plugin: 'kotlin'
18+
apply plugin: 'jacoco'
2619

2720
repositories {
2821
maven { url "https://dl.bintray.com/kotlin/kotlin-eap-1.1" }
2922
jcenter()
3023
}
3124

25+
jacocoTestReport {
26+
reports {
27+
xml.enabled true
28+
}
29+
}
30+
3231
dependencies {
3332
compile "org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION"
3433
compile group: 'org.assertj', name: 'assertj-core', version: '2.5.0'

src/main/kotlin/com/memoizr/assertk/AssertionHooks.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface AssertionHook {
1313
infix fun that(subjectUnderTest: Float?) = FloatAssert(subjectUnderTest)
1414
infix fun that(subjectUnderTest: Double?) = DoubleAssert(subjectUnderTest)
1515
infix fun that(subjectUnderTest: Long?) = LongAssert(subjectUnderTest)
16+
infix fun that(subjectUnderTest: Boolean?) = BooleanAssert(subjectUnderTest)
1617
}
1718

1819
class RealAssertionHook : AssertionHook
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.memoizr.assertk
2+
3+
import org.assertj.core.api.AbstractBooleanAssert
4+
import org.assertj.core.api.Assertions
5+
6+
class BooleanAssert internal constructor(
7+
subjectUnderTest: Boolean?,
8+
override val assertion: AbstractBooleanAssert<*> = Assertions.assertThat(subjectUnderTest)) :
9+
AbstractAssertBuilder<BooleanAssert, Boolean>(subjectUnderTest, BooleanAssert::class.java) {
10+
11+
infix fun _is(other: Boolean): BooleanAssert {
12+
if (other) assertion.isTrue() else assertion.isFalse()
13+
return this
14+
}
15+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.memoizr.assertk
2+
3+
import com.nhaarman.mockito_kotlin.never
4+
import com.nhaarman.mockito_kotlin.spy
5+
import com.nhaarman.mockito_kotlin.verify
6+
import org.assertj.core.api.AbstractBooleanAssert
7+
import org.assertj.core.api.Assertions
8+
import org.junit.Test
9+
10+
class `BooleanAssert test` {
11+
lateinit var mockAssertion: AbstractBooleanAssert<*>
12+
@Suppress("UNCHECKED_CAST")
13+
val _expect = object : AssertionHook {
14+
override fun that(subjectUnderTest: Boolean?): BooleanAssert {
15+
val spy: AbstractBooleanAssert<*> = spy(Assertions.assertThat(subjectUnderTest))
16+
mockAssertion = spy
17+
return BooleanAssert(subjectUnderTest, mockAssertion)
18+
}
19+
}
20+
21+
val chained = Any()
22+
infix fun BooleanAssert.andCanBe(chained: Any) = this
23+
24+
@Test
25+
fun isTrue() {
26+
_expect that true _is true andCanBe chained
27+
verify(mockAssertion).isTrue()
28+
verify(mockAssertion, never()).isFalse()
29+
}
30+
31+
@Test
32+
fun isFalse() {
33+
_expect that false _is false andCanBe chained
34+
verify(mockAssertion).isFalse()
35+
verify(mockAssertion, never()).isTrue()
36+
}
37+
}

0 commit comments

Comments
 (0)