Added MainRunner. This removes the need for public methods in JUnitCore #370

Merged
merged 2 commits into from Apr 3, 2012

3 participants

@matthewfarwell

MainRunner installs a SecurityManager which traps the System.exit(), thereby
removing the need to have runMainAndExit and runMain public in JUnitCore.
MainRunner is only used in the tests of course.

The idea of this change is to remove the public methods runMainAndExit and runMain.

@matthewfarwell matthewfarwell Added MainRunner. This removes the need for public methods in JUnitCore
MainRunner installs a SecurityManager which traps the System.exit(), thereby
removing the need to have runMainAndExit and runMain public in JUnitCore.
MainRunner is only used in the tests of course.
917a88f
@dsaff
JUnit member

I like this, in general. Can you run some github searches, and post quickly on junit-users, to make sure there are no non-test users of these methods?

@matthewfarwell

Posted to junit group, the github search reveals two projects:

https://github.com/SteMo/Zeiterfassung_HiWis_TUD (single use)
https://github.com/gliptak/JAllele (mutliple uses, but > 2 years since last update)

@stefanbirkner

This security manager may cause some trouble. I learned it the hard way on my System Rules project :-) What you should use is something like https://github.com/stefanbirkner/system-rules/blob/master/src/main/java/org/junit/contrib/java/lang/system/internal/NoExitSecurityManager.java
You can copy the code. It's mine.

Thanks for that. I'll incorporate it when I've got half an hour. What were the problems that you encountered? Anything I should know about, or just that we should be delegating everything to the original security manager?

Somebody I know had problems with tests, that test JMX functionality.

@dsaff dsaff merged commit d5bce27 into junit-team:master Apr 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment