Created
August 11, 2011 16:22
-
-
Save abyx/1140074 to your computer and use it in GitHub Desktop.
Reusing context with JUnit Enclosed runner
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
@RunWith(Enclosed.class) | |
public class OuterClassTest { | |
@Mock protected Dependency dependency; | |
protected SUT subject; | |
@Before | |
public void setUp() { | |
subject = new SUT(dependency); | |
} | |
@RunWith(MockitoJUnitRunner.class) | |
public static class FirstScope extends OuterClassTest { | |
@Test | |
public void someTest() { | |
subject.doSomething(); | |
verify(subject).didSomething(); | |
} | |
} | |
@RunWith(MockitoJUnitRunner.class) | |
public static class SecondScope extends OuterClassTest { | |
@Test | |
public void differentTest() { | |
subject.doSomethingElse(); | |
verify(subject).didSomething(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment