TestNG-无法从控制台获取输入

问题描述 投票:0回答:1

我正尝试通过@BeforeSuite通知测试人员有问题。我的代码将信息输出到控制台,并等待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();
        }
    }
}
java testng
1个回答
0
投票

您可以尝试int i = System.in.read(); System.out.println(I);然后在输入任何字符时,其ascii值将作为响应返回。

© www.soinside.com 2019 - 2024. All rights reserved.