TestNG - 无法从控制台获取输入
TestNG - can't get input from console
我正在尝试将@BeforeSuite 上的问题通知测试人员。
我的代码将信息打印到控制台并等待 Enter 或任意键。
由于某种原因,我的代码卡住了,我没有看到任何错误或异常。
我输入了几次 enter 但没有任何反应。
请帮忙。
@BeforeSuite(alwaysRun = true)
@Parameters({ "suite-param" })
public void beforeSuite(ITestContext testContext, @Optional String suiteFile) throws Exception {
//some condition in here
if (true ) {
ConsoleLogger.info("You are running COMPARE Mode");
ConsoleLogger.info("createBaseLine=false on your testProps");
System.out.println("Press enter to continue...");
try {
System.in.read();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
你可以试试 int i=System.in.read(); System.out.println(我);然后在输入任何字符时,其 ascii 值将作为响应返回。
我正在尝试将@BeforeSuite 上的问题通知测试人员。
我的代码将信息打印到控制台并等待 Enter 或任意键。
由于某种原因,我的代码卡住了,我没有看到任何错误或异常。
我输入了几次 enter 但没有任何反应。
请帮忙。
@BeforeSuite(alwaysRun = true)
@Parameters({ "suite-param" })
public void beforeSuite(ITestContext testContext, @Optional String suiteFile) throws Exception {
//some condition in here
if (true ) {
ConsoleLogger.info("You are running COMPARE Mode");
ConsoleLogger.info("createBaseLine=false on your testProps");
System.out.println("Press enter to continue...");
try {
System.in.read();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
你可以试试 int i=System.in.read(); System.out.println(我);然后在输入任何字符时,其 ascii 值将作为响应返回。