TestNG控制台输出到log4j.log [英] TestNG console output into log4j.log

查看:771
本文介绍了TestNG控制台输出到log4j.log的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将输出结果(失败或成功)输入到log4j输出中.

I need to get output result (FAIL or SUCCESS) into log4j output.

Assert.assertTrue(availresponse);

有什么方法可以将TestNG控制台输出添加到log4j.log文件中?

Is there any way to add TestNG console output into log4j.log file?

推荐答案

最后找到在log4j中记录Assert error的最简单方法
catch block中,如果不是Exception,则应为Throwable.

Finally found the easiest way to log the Assert error in log4j
In catch block it should be Throwable, if it is Exception that will not work.

try {
    Assert.assertTrue(hotel.getAmenitiesList().size() < 0, "Hotel Amenities Available!");

} catch (Throwable e) {
    e.printStackTrace();
    logger.error("FAILED: testRoomAmenities ", e);
    Assert.fail();

此工具将不作为FAIL调用.它将显示方案为PASSED.因此,您应该使用Assert.fail()使其为FAILED

When this implement that will not invoke as FAIL. It will show that scenario is PASSED. Therefore you should use Assert.fail() to make that is FAILED

这篇关于TestNG控制台输出到log4j.log的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆