Created
December 7, 2009 22:31
-
-
Save domix/251192 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package testing; | |
import static org.junit.Assert.assertFalse; | |
import static org.junit.Assert.assertNotNull; | |
import static org.junit.Assert.assertTrue; | |
import static org.mockito.Mockito.when; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.Mock; | |
@RunWith(MockInyectRunner.class) | |
public class UnderTestTest { | |
@UnderTest | |
private UnderTestObject longi; | |
@Mock | |
private Colaborator colaboradorEnTest; | |
@Mock | |
private Colaborator1 colaborador1EnTest; | |
@Before | |
public void foo() { | |
System.out.println("En el before"); | |
} | |
@Test | |
public void testname() throws Exception { | |
when(colaboradorEnTest.foo()).thenReturn(true); | |
when(colaborador1EnTest.foo()).thenReturn(false); | |
assertNotNull(longi); | |
assertTrue(longi.foo()); | |
assertFalse(longi.bar()); | |
} | |
} | |
class UnderTestObject { | |
private Colaborator colaborador; | |
private Colaborator1 colaborador1; | |
public boolean foo() { | |
return colaborador.foo(); | |
} | |
public boolean bar() { | |
return colaborador1.foo(); | |
} | |
} | |
class Colaborator { | |
public boolean foo() { | |
return false; | |
} | |
} | |
class Colaborator1 { | |
public boolean foo() { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment