Skip to content

Instantly share code, notes, and snippets.

@trickyBytes
Created April 11, 2018 14:35
Show Gist options
  • Save trickyBytes/60771fd044067e1ce5af530249e35ae8 to your computer and use it in GitHub Desktop.
Save trickyBytes/60771fd044067e1ce5af530249e35ae8 to your computer and use it in GitHub Desktop.
Exposing the instantiation of an inner context for testing.
public class Enclosing {
public String methodA() {
getContext();
......
}
protected void getContext() {
Inner.getContext();
......
}
@Test
public void test_something() {
Enclosing enclosing = new Enclosing() {
@Override
protected void getContext() {
// do what you need here
}
};
// your test code on enclosing where you control getContext
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment