Junit主函数被调用两次

问题描述

使用预期的系统出口时出现问题 当使用args调用主类时,输出将输出两次,并且当我尝试使用ExpectedSystemExit运行时,它可以正常工作,但是由于它在main中具有exit(0),因此我面临着这个问题

public class Test {
    @Rule
    public final ExpectedSystemExit exit = ExpectedSystemExit.none();

    @Test
   public void Creation() throws Exception {
        exit.expectSystemExitWithStatus(0);;
        exit.checkAssertionAfterwards(new Assertion() {
            @Override
            public void checkAssertion() throws Exception {
                System.out.println("Main called twice we can ignore the above ERROR");
            }
        });
Generator class for testing main function present inside it 

从本地目录中选择文件 Generator.main(new String [] {“ Input Path”}); }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)