So let's say I have an interface called ExitInterface.java. Inside there is only one method declaration, exit().
I have two classes that implement this:
1) first one is named Exit.java which does System.exit(exitCode) in the exit method.
2) second one named ExitMock.java which doesn't exit, and instead keeps track of the exitCode in a field so it can be tested on in junit.
I can't seem to test the ExitMock from my program because the class that uses Exit has an instance of ExitInterface, which is normally initiated as Exit and when I'm testing I change it to initialize as ExitMock, but it won't let me access ExitMock's fields because it's not in ExitInterface. Even if I try wrapping it or adding some get/set methods, nothing works.
Does anyone know of a method I can fix this?