mockito / mockito-kotlin

Using Mockito with Kotlin
MIT License
3.11k stars 202 forks source link

The project doesn't pass the tests #359

Open BraisGabin opened 5 years ago

BraisGabin commented 5 years ago

I just cloned the repo and runed ./gradlew test and the project failed with lots of errors

w: /Users/brais/projects/mockito-kotlin/mockito-kotlin/src/main/kotlin/com/nhaarman/mockitokotlin2/internal/CreateInstance.kt: (45, 30): Parameter 'kClass' is never used
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (5, 21): Unresolved reference: mockitokotlin2
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (14, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (20, 22): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (21, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (28, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (34, 34): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (35, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (36, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (44, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (50, 43): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (51, 27): Unresolved reference: KArgumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (63, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (69, 52): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (70, 27): Unresolved reference: KArgumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (83, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (89, 61): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (90, 27): Unresolved reference: KArgumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (104, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (110, 22): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (111, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (118, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (124, 22): Unresolved reference: nullableArgumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (125, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (132, 26): Unresolved reference: mock
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (139, 22): Unresolved reference: argumentCaptor
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (140, 9): Unresolved reference: verify
e: /Users/brais/projects/mockito-kotlin/tests/src/test/kotlin/test/ArgumentCaptorTest.kt: (140, 22): Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
@InlineOnly public inline operator fun BigDecimal.times(other: BigDecimal): BigDecimal defined in kotlin
@InlineOnly public inline operator fun BigInteger.times(other: BigInteger): BigInteger defined in kotlin
...

I fixed it changing the file tests/build.gradle:

- compile files("${rootProject.projectDir}/mockito-kotlin/build/libs/mockito-kotlin-${rootProject.ext.versionName}.jar")
+ compile project(":mockito-kotlin")

I don't know why the project is picked in that way. If there is not a good reason for do it that way I have the commit that does the change: 10faa1f2491fab6c9a1439d225fd382402603955 so I can create the PR if you want.

nhaarman commented 5 years ago

Yeah the repo is not really set up to deal with this in a friendly way. It is set up to run tests against multiple Kotlin versions. The base module now uses Kotlin 1.3.x, the test module uses a configured Kotlin version, see https://github.com/nhaarman/mockito-kotlin/tree/2.x/tests

Running tests locally requires a ./gradlew assemble first:

./gradlew assemble && ./gradlew test

This should pass on your machine.

BraisGabin commented 5 years ago

That have sense. Maybe a line in the readme about how to build this would be great to make the contributions easier.