Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Verifications fail with Missing calls inside verify { ... } block when ran on CLI but pass in IDE #259

Closed
3 tasks done
mp911de opened this issue Feb 20, 2019 · 10 comments
Labels
bug fixed fixed in master

Comments

@mp911de
Copy link

mp911de commented Feb 20, 2019

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • I am running the latest version
  • I checked the documentation and found no answer
  • I checked to make sure that this issue has not already been filed

Expected Behavior

Verification is properly evaluated.

Current Behavior

The test fails with: Missing calls inside verify { ... } block

Failure Information (for bugs)

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. See code
  2. Run CriteriaExtensionsUnitTests

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • MockK version: 1.9.1
  • OS: MacOS 10.14.2
  • Kotlin version: tested on 1.3.11 and 1.3.21
  • JDK version: JRE 1.8.0_121-b13
  • JUnit version: 4.12
  • Type of test: JUnit 4 test

Stack trace

io.mockk.MockKException: Missing calls inside verify { ... } block.
	at org.springframework.data.cassandra.core.query.CriteriaExtensionsUnitTests.inValues(varags) extension should support nullable values(CriteriaExtensionsUnitTests.kt:66)

Minimal reproducible code (the gist of this issue)

class CriteriaExtensionsUnitTests {

	val criteria = mockk<Criteria>(relaxed = true)

	@Test
	fun `inValues(Collection) extension should call its Java counterpart`() {

		val c = listOf("foo", "bar")

		criteria.inValues(c)

		verify { criteria.`in`(c) }
	}
}
/**
 * Extension for [Criteria. in] providing an `inValues` alias since `in` is a reserved keyword in Kotlin.
 */
fun <T : Any?> Criteria.inValues(c: Collection<T>): Criteria = `in`(c)
public class Criteria {
	public Criteria in(Collection<?> values) {
		return this;
	}
}

See also: https://github.com/spring-projects/spring-data-cassandra/blob/master/spring-data-cassandra/src/test/kotlin/org/springframework/data/cassandra/core/query/CriteriaExtensionsUnitTests.kt#L75-L81

@mp911de mp911de changed the title Verifications fail when Missing calls inside verify { ... } block when ran on CLI but pass in IDE Verifications fail with Missing calls inside verify { ... } block when ran on CLI but pass in IDE Feb 20, 2019
mp911de added a commit to spring-projects/spring-data-cassandra that referenced this issue Feb 20, 2019
@oleksiyp
Copy link
Collaborator

Thanks for the report. Will check

@oleksiyp
Copy link
Collaborator

Spent some time on this issue. Instrumention is OK. Turned off parallel testing , but that did not help. In trace logs call doesn't get intercepted. Probably something related to class loading. Will spend more time on weekends

@mp911de
Copy link
Author

mp911de commented Feb 21, 2019

Can this be related to Surefire 2.22.1?

@oleksiyp
Copy link
Collaborator

oleksiyp commented Feb 21, 2019

Very probable, as JUnit 4.12 is widely used and no other things to interact with. ByteBuddy seems to be working as one test passing and transformed classes are OK

@oleksiyp
Copy link
Collaborator

oleksiyp commented Mar 8, 2019

Seems problem appears when building with 2.19 and above Surefire plugin.

@oleksiyp
Copy link
Collaborator

oleksiyp commented Mar 8, 2019

I experimented a lot with this error.

Turned on debugging, double-checked all the maps inside of mockk, e.t.c. Nothing too suspicious. Looks like not always instrumentation take place at the moment it is requested, maybe not for all threads at a time, or maybe there is a race condition in mockk code. Actually I am starting to understand it better, but let's see. The problem now is to reproduce it without surefire.

Currently, all my achievement in reproduction and differentiation is that I know if I put sleep(500) after mock intialization it won't fail.

image

@oleksiyp
Copy link
Collaborator

oleksiyp commented Mar 8, 2019

Good news 😄

I reproduced it.

image

@oleksiyp oleksiyp added the fixed fixed in master label Mar 9, 2019
@oleksiyp
Copy link
Collaborator

@mp911de please try the same test with version 1.9.2 or 1.9.2.kotlin12. Thanks

@mp911de
Copy link
Author

mp911de commented Mar 11, 2019

Thanks a lot. The fix addressed the issue.

@stale
Copy link

stale bot commented Aug 8, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you are sure that this issue is important and should not be marked as stale just ask to put an important label.

@stale stale bot added the stale label Aug 8, 2019
@stale stale bot closed this as completed Aug 15, 2019
@oleksiyp oleksiyp added bug and removed stale labels Nov 2, 2019
@oleksiyp oleksiyp changed the title Verifications fail with Missing calls inside verify { ... } block when ran on CLI but pass in IDE Bug: Verifications fail with Missing calls inside verify { ... } block when ran on CLI but pass in IDE Nov 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed fixed in master
Projects
None yet
Development

No branches or pull requests

2 participants