C
Chenxi
hello
i've written a small programme and want to test the main method. the problem
is that if the parameters are wrong and the programme terminates, JUnit
cannot detect it and the test result would be pass. if i use System.exit(1),
JUnit cannot catch the termination status and the result will be that the
test is still running.
How can i let the unit test know whether the programme fails or succeeds?
==================
public class A{
public A{}
.......
public static void main(String[] args){
if (args.length<2){
System.out.println("wrong parameters");
return;
// System.exit(1);
}
......
}
=================
--
i've written a small programme and want to test the main method. the problem
is that if the parameters are wrong and the programme terminates, JUnit
cannot detect it and the test result would be pass. if i use System.exit(1),
JUnit cannot catch the termination status and the result will be that the
test is still running.
How can i let the unit test know whether the programme fails or succeeds?
==================
public class A{
public A{}
.......
public static void main(String[] args){
if (args.length<2){
System.out.println("wrong parameters");
return;
// System.exit(1);
}
......
}
=================
--