Question

Does JUnit has a build it feature to ask user interactively about test succeeded?

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.

Also I know I can popup dialog myself but I am wondering whether JUnit has something premade.

Was it helpful?

Solution

Have you considered using System.setIn statements.

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
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top