I have to write a Test case in JUnit
for a Class
lets call it C1
which internally calls Runtime.getRuntime.exit(somevalue)
.
The class C1
has a main
method which accepts some arguments
and the creates a CommandLine
and then depending on the passed arguments
does the specific tasks.
Now all tasks after executing call a Runtime.getRuntime.exit(somevalue)
. The somevalue
defines whether the task was executed successfully (means somevalue is 0) or had errors (means somevalue is 1).
In the JUnit test case of this I have to get this somevalue
and check whether it is the desired somevalue
or not.
How do I get the somevalue
in the JUnit test case.