Skip to content

Commit

Permalink
Merge pull request #98 from nhaarman/release-0.9.0
Browse files Browse the repository at this point in the history
Release 0.9.0
  • Loading branch information
nhaarman authored Oct 21, 2016
2 parents 5878bbe + 6126454 commit 24108bd
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 83 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Mockito-Kotlin
[ ![Download](https://api.bintray.com/packages/nhaarman/maven/Mockito-Kotlin/images/download.svg) ](https://bintray.com/nhaarman/maven/Mockito-Kotlin/_latestVersion)
[ ![Download](https://maven-badges.herokuapp.com/maven-central/com.nhaarman/mockito-kotlin/badge.svg) ](https://maven-badges.herokuapp.com/maven-central/com.nhaarman/mockito-kotlin)

A small library that provides helper functions to work with [Mockito](https://github.com/mockito/mockito) in Kotlin.

## Install

Mockito-Kotlin is available on JCenter.
For Gradle users, add the following to your `build.gradle`:
Mockito-Kotlin is available on Maven Central.
For Gradle users, add the following to your `build.gradle`, replacing `x.x.x` with the latest version:

```groovy
repositories {
jcenter()
mavenCentral()
}
dependencies {
testCompile "com.nhaarman:mockito-kotlin:x.x.x"
Expand Down
6 changes: 6 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
To publish a release:

- Tag the commit on master: `git tag -a x.x.x -m x.x.x && git push --tags`
- Execute the release process: `./gradlew clean test uploadArchives -PisRelease=true`
- Head to https://oss.sonatype.org/#stagingRepositories to close and release the deployment.
- Don't forget to publish the tag on Github with release notes :)
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
plugins {
id "com.jfrog.bintray" version "1.7.1"
id 'com.github.ben-manes.versions' version '0.13.0'
}
apply plugin: 'maven'
apply plugin: 'maven-publish'

apply from: 'gradle/scripts/tagging.gradle'
17 changes: 16 additions & 1 deletion mockito-kotlin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
apply plugin: 'kotlin'
apply from: './publishing.gradle'
apply plugin: 'org.jetbrains.dokka'

buildscript {
ext.kotlin_version = '1.0.4'

repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.9"
}
}

Expand Down Expand Up @@ -42,9 +45,21 @@ test.dependsOn testInlineMockito
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"
compile "org.mockito:mockito-core:2.2.6"

/* Tests */
testCompile "junit:junit:4.12"
testCompile "com.nhaarman:expect.kt:0.6.0"
}

dokka {
outputFormat = 'html'
outputDirectory = "$buildDir/javadoc"

linkMapping {
dir = "src/main/kotlin"
url = "https://github.com/nhaarman/mockito-kotlin/tree/master/mockito-kotlin/src/main/kotlin"
suffix = "#L"
}
}
javadoc.dependsOn dokka
93 changes: 60 additions & 33 deletions mockito-kotlin/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,44 +1,71 @@
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar

groupId 'com.nhaarman'
artifactId 'mockito-kotlin'
version rootProject.ext.versionName
}
}
}
apply plugin: 'maven'
apply plugin: 'signing'

bintray {
user = hasProperty('bintray_user') ? bintray_user : System.getenv('BINTRAY_USER')
key = hasProperty('bintray_key') ? bintray_key : System.getenv('BINTRAY_KEY')
publications = ['MyPublication']
group = 'com.nhaarman'
version = rootProject.ext.versionName
def sonatypeUsername = hasProperty('sonatype_username') ? sonatype_username : System.getenv('SONATYPE_USERNAME')
def sonatypePassword = hasProperty('sonatype_password') ? sonatype_password : System.getenv('SONATYPE_PASSWORD')

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'
from 'build/javadoc'
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}

artifacts {
archives jar

archives javadocJar
archives sourcesJar
}

signing {
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(
userName: sonatypeUsername,
password: sonatypePassword
)
}

pom.project {
name 'Mockito-Kotlin'
packaging 'jar'
description 'Using Mockito with Kotlin.'
url 'https://github.com/nhaarman/mockito-kotlin'

scm {
url 'scm:[email protected]:nhaarman/mockito-kotlin.git'
connection 'scm:[email protected]:nhaarman/mockito-kotlin.git'
developerConnection 'scm:[email protected]:nhaarman/mockito-kotlin.git'
}

licenses {
license {
name 'MIT'
distribution 'repo'
}
}

developers {
developer {
id 'nhaarman'
name 'Niek Haarman'
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline fun <reified T : Any> argumentCaptor(): KArgumentCaptor<T> = KArgumentCap

inline fun <reified T : Any> capture(captor: ArgumentCaptor<T>): T = captor.capture() ?: createInstance<T>()

@Deprecated("Use captor.capture() instead.", ReplaceWith("captor.capture()"))
@Deprecated("Use captor.capture() instead.", ReplaceWith("captor.capture()"), DeprecationLevel.ERROR)
inline fun <reified T : Any> capture(captor: KArgumentCaptor<T>): T = captor.capture()

class KArgumentCaptor<out T : Any>(private val captor: ArgumentCaptor<T>, private val tClass: KClass<T>) {
Expand All @@ -51,7 +51,7 @@ class KArgumentCaptor<out T : Any>(private val captor: ArgumentCaptor<T>, privat
* Instead, use [argumentCaptor] in the traditional way, or use one of
* [argThat], [argForWhich] or [check].
*/
@Deprecated("Use argumentCaptor() or argThat() instead.")
@Deprecated("Use argumentCaptor() or argThat() instead.", ReplaceWith("check(consumer)"), DeprecationLevel.ERROR)
inline fun <reified T : Any> capture(noinline consumer: (T) -> Unit): T {
var times = 0
return argThat { if (++times == 1) consumer.invoke(this); true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ fun verifyZeroInteractions(vararg mocks: Any) = Mockito.verifyZeroInteractions(*
fun <T> whenever(methodCall: T): OngoingStubbing<T> = Mockito.`when`(methodCall)!!
fun withSettings(): MockSettings = Mockito.withSettings()!!

@Deprecated("Use any() instead.", ReplaceWith("any()"))
@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR)
inline fun <reified T : Any> anyCollection(): Collection<T> = any()

@Deprecated("Use any() instead.", ReplaceWith("any()"))
@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR)
inline fun <reified T : Any> anyList(): List<T> = any()

@Deprecated("Use any() instead.", ReplaceWith("any()"))
@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR)
inline fun <reified T : Any> anySet(): Set<T> = any()

@Deprecated("Use any() instead.", ReplaceWith("any()"))
@Deprecated("Use any() instead.", ReplaceWith("any()"), DeprecationLevel.ERROR)
inline fun <reified K : Any, reified V : Any> anyMap(): Map<K, V> = any()
36 changes: 0 additions & 36 deletions mockito-kotlin/src/test/kotlin/MockitoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,42 +73,6 @@ class MockitoTest {
}
}

@Test
fun anyCollectionOfClosed() {
mock<Methods>().apply {
closedCollection(listOf())
verify(this).closedCollection(any())
verify(this).closedCollection(anyCollection())
}
}

@Test
fun anyListOfClosed() {
mock<Methods>().apply {
closedList(listOf())
verify(this).closedList(any())
verify(this).closedList(anyList())
}
}

@Test
fun anyClosedStringMap() {
mock<Methods>().apply {
closedStringMap(mapOf())
verify(this).closedStringMap(any())
verify(this).closedStringMap(anyMap())
}
}

@Test
fun anyClosedSet() {
mock<Methods>().apply {
closedSet(setOf())
verify(this).closedSet(any())
verify(this).closedSet(anySet())
}
}

@Test
fun anyStringVararg() {
mock<Methods>().apply {
Expand Down

0 comments on commit 24108bd

Please sign in to comment.