0

i want to stub kotlin's map extension function in my unit test. couldn't find any proper solution on internet to do that.

ctually i have put empty blocks inside curly brackets but it seems like this is not the way that i should do.

here is what i have been trying so far:

whenever(trainWorkoutResult.exerciseSections.map {}).thenReturn(trainSections)

here is the error that i got:

no answer found for: 

    LegacyDataMapper(#4).mappingSectionsToRecordedExerciseDataModels(Mock for List, hashCode: 1199894489)

any idea?

aligur
  • 3,387
  • 3
  • 34
  • 51

1 Answers1

0

solved it like that:

 with(mockk<List<Section>>()) {
                every {
                    trainWorkoutResult.exerciseSections
                } returns (listOf(Section(12, "123", emptyList())))
            }

inspired by this question.

ps: i am using mockk library

aligur
  • 3,387
  • 3
  • 34
  • 51