1

captor value return null. Using ArgumentCaptor for the parameter in the method for unit test, but it returns null

@Captor
    private lateinit var getCallbackCaptor: ArgumentCaptor<DataSource.GetCallback<Response>>

@Before init(){
 MockitoAnnotations.initMocks(this)
 videoViewModel = VideoViewModel(remoteRepository)
}

@Test test1(){

 videoViewModel.setUpConference(conferenceToken)

 verify<Repository>(remoteRepository).setUpConferenceRequest(
                conferenceToken,
                getCallbackCaptor.capture()
            )


}

Thanks

Edric
  • 24,639
  • 13
  • 81
  • 91
Kumar Kalluri
  • 493
  • 2
  • 6
  • 26
  • Where did you define the behaviour for the mock, when `setUpConferenceRequest` is called? Consider providing a [mre] that includes the definition of `remoteRepository` as well as the class under test. – second Jan 20 '20 at 16:23
  • Please post your stacktrace. – Reaz Murshed Jan 24 '20 at 18:22
  • I think your problem is caused by kotlin, check out https://stackoverflow.com/questions/34773958/kotlin-and-argumentcaptor-illegalstateexception – handhand May 14 '20 at 03:03

0 Answers0