File tree Expand file tree Collapse file tree 6 files changed +64
-12
lines changed
main/kotlin/com/memoizr/assertk
test/kotlin/com/memoizr/assertk Expand file tree Collapse file tree 6 files changed +64
-12
lines changed Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ language: java
2
2
jdk :
3
3
- oraclejdk8
4
4
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
Original file line number Diff line number Diff line change 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
+
4
3
# AssertK - Fluent assertions for Kotlin
5
4
AssertK provides a Kotlin-friendly syntax for using the amazing AssertJ assertion framework.
6
5
Original file line number Diff line number Diff line change @@ -11,24 +11,23 @@ buildscript {
11
11
}
12
12
}
13
13
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' ]
22
14
group ' com.memoizr'
23
15
version ' 0.1'
24
16
25
17
apply plugin : ' kotlin'
18
+ apply plugin : ' jacoco'
26
19
27
20
repositories {
28
21
maven { url " https://dl.bintray.com/kotlin/kotlin-eap-1.1" }
29
22
jcenter()
30
23
}
31
24
25
+ jacocoTestReport {
26
+ reports {
27
+ xml. enabled true
28
+ }
29
+ }
30
+
32
31
dependencies {
33
32
compile " org.jetbrains.kotlin:kotlin-stdlib:$KOTLIN_VERSION "
34
33
compile group : ' org.assertj' , name : ' assertj-core' , version : ' 2.5.0'
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ interface AssertionHook {
13
13
infix fun that (subjectUnderTest : Float? ) = FloatAssert (subjectUnderTest)
14
14
infix fun that (subjectUnderTest : Double? ) = DoubleAssert (subjectUnderTest)
15
15
infix fun that (subjectUnderTest : Long? ) = LongAssert (subjectUnderTest)
16
+ infix fun that (subjectUnderTest : Boolean? ) = BooleanAssert (subjectUnderTest)
16
17
}
17
18
18
19
class RealAssertionHook : AssertionHook
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments