Steve
02/07/2020, 2:20 AMnapperley
02/17/2020, 2:23 AMJoffrey
03/16/2020, 9:43 AMassertFailsWith
?
When using it in a multiplatform project, I can consistently reproduce an issue on the JS platform (everything is fine on JVM).
When I use assertFailsWith(SomeException::class)
everything works as expected (the exception is thrown, the test pass). When I use assertFailsWith<SomeException>
variant, the test fails as if no exception was thrown by the block.
Only a couple of my tests work properly no matter the form used, but all the others fail consistently with the 2nd form and succeed with the 1st form, and I have no idea how this is possible, both are inline functions calling the same 3rd function… I really don’t get it.Daniele Segato
09/09/2020, 8:58 AM`when`(api.method())
.then { throw anError }
.thenReturn(something)
which basically meant: first time it is called throw anError
, second time return something
Is there a way to do something like this with MockK?Daniele Segato
01/22/2021, 4:54 PMfun createCoroutineScope(): CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
So in my test I have to check if the returned CoroutineScope
is using a SupervisedJob
or a particular Dispatcher
how do I do that??
(or any other property of the context/scope)
For instance, say I wanna write an unit test that force me to create a CoroutineScope(SupervisorJob())
@Test
fun createCoroutineScope_produce_a_supervisor_job() {
val scope = createCoroutineScope()
val job = scope.coroutineContext[Job]
assertTrue(job is SupervisorJob) // can't do
}
SupervisorJob
is not an interface or a class, it's a top level function. It's implementation tells me nothing about what kind of job it is or how it handle children. The implementation is private.
I cannot find a way to force me to write that code from an unit test, can anyone enlighten me?
(I've asked this in #getting-started but I realized it is better suited here + I asked it better here)Andrew Ebling
02/15/2021, 10:21 AMsubject.openThePodBayDoors()
verify(mockDoorManager).completion(Mockito.any())
...then I get an error:
java.lang.IllegalStateException: Mockito.any() must not be null
...even though I have written the production code which should make this test pass.
I’ve been googling “kotlin mockito match any lambda” etc. and can find complex tests with LambdaMatcher
but all I want to do is check that the method was called with some lamba - I don’t even care what it does for this test. There must be a simple solution for this I’m missing, surely?Nikolay Kasyanov
03/03/2021, 11:21 AMkotlin-test-junit
dependency is added, junit
should also be added explicitly?sendoav
03/29/2021, 2:55 PMChris Jobling
05/21/2021, 3:38 PMTobi M.
11/24/2021, 9:12 AMColton Idle
02/04/2022, 2:30 PMColton Idle
02/07/2022, 9:42 PMBig Chungus
06/22/2022, 8:20 PMoianmol
10/28/2022, 7:05 AMLandry Norris
11/17/2022, 3:07 PMteddy
12/02/2022, 12:29 AMNarayan Iyer
12/14/2022, 1:02 PMBig Chungus
02/20/2023, 10:00 AMBig Chungus
02/20/2023, 10:00 AM