簡體   English   中英

JUnit詢問用戶測試是否成功?

[英]JUnit ask user if test was successful?

JUnit是否具有內置功能,以交互方式詢問用戶測試是否成功?

我知道JUnit是用於自動測試的,但是我有一些聲音生成類,我想通過耳朵進行測試,並希望在一些罕見的一次性運行的情況下手動@Ignore進行測試,然后將@Ignore添加到此類測試中。

我也知道自己可以彈出對話框,但是我想知道JUnit是否有預制的東西。

您是否考慮過使用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