美文网首页Projects记录
System.setOut in JUnit test didn

System.setOut in JUnit test didn

作者: greatseniorsde | 来源:发表于2018-09-29 14:59 被阅读0次

Issue: The expected output is correctly displayed in console, but the JUnit actual value is "" which leads to assertion error and test failure.

Similar problem: https://stackoverflow.com/questions/46712632/systemoutrule-in-junit-test-didnt-capture-standard-output

After reading the solution on stackoverflow, I suspect it is caused by the version of JUnit. Then I took a closer look at another test java file that works to compare the one that doesn't work, and I found that it's true that I imported different version of JUnit in them, so I changed the imported file and then things worked fine.

//The commented ones don't work.
//import org.junit.*;
//import org.junit.jupiter.api.Test;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

相关文章

网友评论

    本文标题:System.setOut in JUnit test didn

    本文链接:https://www.haomeiwen.com/subject/adtboftx.html