Skip to content

Instantly share code, notes, and snippets.

@esmasui
Last active August 29, 2015 14:23
Show Gist options
  • Save esmasui/4c8fb6900972af4d5046 to your computer and use it in GitHub Desktop.
Save esmasui/4c8fb6900972af4d5046 to your computer and use it in GitHub Desktop.
package com.uphyca.mockitoonart;
import org.mockito.Mock;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class NoArgsInterfaceMethodTest extends MockitoTestCase {
@Mock
TargetInterface underTest;
public void testThatWorkProperly() throws Exception {
try {
when(underTest.sayGoodbye()).thenReturn("Goodbye, Mockito");
//Failed with Mockito 1.9.5/dexmaker-mockito 1.1
fail();
}catch (IllegalArgumentException expected) {
}
//assertThat(underTest.sayGoodbye()).isEqualTo("Goodbye, Mockito");
//verify(underTest).sayGoodbye();
}
}
package com.uphyca.mockitoonart;
import org.mockito.Mock;
import static org.fest.assertions.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class NoArgsInterfaceMethodTest extends MockitoTestCase {
@Mock
TargetInterface underTest;
public void testThatWorkProperly() throws Exception {
when(underTest.sayGoodbye()).thenReturn("Goodbye, Mockito");
assertThat(underTest.sayGoodbye()).isEqualTo("Goodbye, Mockito");
verify(underTest).sayGoodbye();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment