简体   繁体   English

JUnit询问用户测试是否成功?

[英]JUnit ask user if test was successful?

Does JUnit has a build it feature to ask user interactively about test succeeded? JUnit是否具有内置功能,以交互方式询问用户测试是否成功?

I know JUnit is for automatic testing, but I have some sound generating classes which I want to test by ear and want in some rare one-run cases to test them manually and then add @Ignore to such tests. 我知道JUnit是用于自动测试的,但是我有一些声音生成类,我想通过耳朵进行测试,并希望在一些罕见的一次性运行的情况下手动@Ignore进行测试,然后将@Ignore添加到此类测试中。

Also I know I can popup dialog myself but I am wondering whether JUnit has something premade. 我也知道自己可以弹出对话框,但是我想知道JUnit是否有预制的东西。

Have you considered using System.setIn statements. 您是否考虑过使用System.setIn语句。

System.out.println("Confirm if you find blah blah working? Enter Y/N ");

System.setIn(new ByteArrayInputStream(data.getBytes()));
Scanner scanner = new Scanner(System.in);
String userInput = scanner.nextLine();

if(userInput.equalsIgnoreCase("Y")) {
   // Pass the test case
} else {
   //Fail the test case
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM