-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #93 from nhaarman/release-0.8.0
Release 0.8.0
- Loading branch information
Showing
10 changed files
with
345 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,50 @@ | ||
apply plugin: 'kotlin' | ||
apply from: './publishing.gradle' | ||
|
||
buildscript { | ||
ext.kotlin_version = '1.0.4' | ||
ext.kotlin_version = '1.0.4' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
dependencies { | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" | ||
compile "org.mockito:mockito-core:2.1.0" | ||
|
||
/* Tests */ | ||
testCompile "junit:junit:4.12" | ||
testCompile "com.nhaarman:expect.kt:0.6.0" | ||
mavenCentral() | ||
jcenter() | ||
} | ||
|
||
publishing { | ||
publications { | ||
MyPublication(MavenPublication) { | ||
from components.java | ||
artifact javadocJar | ||
artifact sourcesJar | ||
|
||
groupId 'com.nhaarman' | ||
artifactId 'mockito-kotlin' | ||
version rootProject.ext.versionName | ||
sourceSets { | ||
testInlineMockito { | ||
compileClasspath += main.output + test.output | ||
runtimeClasspath += main.output + test.output | ||
} | ||
} | ||
} | ||
|
||
bintray { | ||
user = hasProperty('bintray_user') ? bintray_user : System.getenv('BINTRAY_USER') | ||
key = hasProperty('bintray_key') ? bintray_key : System.getenv('BINTRAY_KEY') | ||
publications = ['MyPublication'] | ||
configurations { | ||
testInlineMockitoCompile.extendsFrom testCompile | ||
testInlineMockitoRuntime.extendsFrom testRuntime | ||
} | ||
|
||
pkg { | ||
repo = 'maven' | ||
name = "Mockito-Kotlin" | ||
desc = "Using Mockito with Kotlin" | ||
// define custom test task for running integration tests | ||
task testInlineMockito(type: Test) { | ||
testClassesDir = sourceSets.testInlineMockito.output.classesDir | ||
classpath = sourceSets.testInlineMockito.runtimeClasspath | ||
} | ||
|
||
licenses = ['MIT'] | ||
vcsUrl = 'https://github.com/bintray/gradle-bintray-plugin.git' | ||
test.dependsOn testInlineMockito | ||
|
||
version { | ||
name = rootProject.ext.versionName | ||
desc = 'Using Mockito with Kotlin' | ||
vcsTag = rootProject.ext.versionName | ||
} | ||
} | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from 'build/docs/javadoc' | ||
} | ||
dependencies { | ||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" | ||
compile "org.mockito:mockito-core:2.2.1" | ||
|
||
task sourcesJar(type: Jar) { | ||
from sourceSets.main.allSource | ||
classifier = 'sources' | ||
/* Tests */ | ||
testCompile "junit:junit:4.12" | ||
testCompile "com.nhaarman:expect.kt:0.6.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
publishing { | ||
publications { | ||
MyPublication(MavenPublication) { | ||
from components.java | ||
artifact javadocJar | ||
artifact sourcesJar | ||
|
||
groupId 'com.nhaarman' | ||
artifactId 'mockito-kotlin' | ||
version rootProject.ext.versionName | ||
} | ||
} | ||
} | ||
|
||
bintray { | ||
user = hasProperty('bintray_user') ? bintray_user : System.getenv('BINTRAY_USER') | ||
key = hasProperty('bintray_key') ? bintray_key : System.getenv('BINTRAY_KEY') | ||
publications = ['MyPublication'] | ||
|
||
pkg { | ||
repo = 'maven' | ||
name = "Mockito-Kotlin" | ||
desc = "Using Mockito with Kotlin" | ||
|
||
licenses = ['MIT'] | ||
vcsUrl = 'https://github.com/bintray/gradle-bintray-plugin.git' | ||
|
||
version { | ||
name = rootProject.ext.versionName | ||
desc = 'Using Mockito with Kotlin' | ||
vcsTag = rootProject.ext.versionName | ||
} | ||
} | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from 'build/docs/javadoc' | ||
} | ||
|
||
task sourcesJar(type: Jar) { | ||
from sourceSets.main.allSource | ||
classifier = 'sources' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,39 @@ | ||
import com.nhaarman.expect.expect | ||
import com.nhaarman.mockito_kotlin.argumentCaptor | ||
import com.nhaarman.mockito_kotlin.mock | ||
import com.nhaarman.mockito_kotlin.times | ||
import com.nhaarman.mockito_kotlin.verify | ||
import com.nhaarman.expect.expect | ||
import com.nhaarman.mockito_kotlin.capture | ||
import org.junit.Test | ||
import java.util.* | ||
|
||
class ArgumentCaptorTest { | ||
|
||
@Test | ||
fun explicitCaptor() { | ||
/* Given */ | ||
val date: Date = mock() | ||
val time = argumentCaptor<Long>() | ||
|
||
/* When */ | ||
date.time = 5L | ||
|
||
verify(date).time = capture(time) | ||
expect(time.value).toBe(5L) | ||
/* Then */ | ||
val captor = argumentCaptor<Long>() | ||
verify(date).time = captor.capture() | ||
expect(captor.value).toBe(5L) | ||
} | ||
|
||
@Test | ||
fun implicitCaptor() { | ||
fun argumentCaptor_multipleValues() { | ||
/* Given */ | ||
val date: Date = mock() | ||
|
||
/* When */ | ||
date.time = 5L | ||
date.time = 7L | ||
|
||
verify(date).time = capture { | ||
expect(it).toBe(5L) | ||
} | ||
/* Then */ | ||
val captor = argumentCaptor<Long>() | ||
verify(date, times(2)).time = captor.capture() | ||
expect(captor.allValues).toBe(listOf(5, 7)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.