https://kotlinlang.org logo
#mockk
Title
# mockk
s

samir

07/02/2018, 10:48 AM
Can’t reproduce with the following, around 10 runs.
Copy code
class SomeClass(val someStr: String) {
	fun someFun() = "abc"
}

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class ConstructorBug {

	@Test
	fun method1() {
		mockkConstructor(SomeClass::class)
		every { anyConstructedSomeClass().someFun() } returns "aaa"

		assertEquals("aaa", SomeClass("1").someFun())

		unmockkConstructor(SomeClass::class)
	}

	@Test
	fun method2() {
		mockkConstructor(SomeClass::class)
		every { anyConstructedSomeClass().someFun() } returns "bbb"

		assertEquals("bbb", SomeClass("2").someFun())

		unmockkConstructor(SomeClass::class)
	}
}