How to get output in both: console and allure report?

5,655 views
Skip to first unread message

garvitag...@gmail.com

unread,
Nov 24, 2017, 5:01:47 AM11/24/17
to testng-users
Hi,

I am using selenium webdriver, testng with allure reporting. There are many scenarios in  my test that require printing something to console. I need it to attach to allure reports too. This is my code :

    @Attachment
    public String logOutput(List<String> outputList) {
        String output = ""; 
        for (String o : outputList) 
            output += o + " "; 
        return output;
    }
    

@AfterMethod
    protected void printLog() throws IOException {
          logOutput(Reporter.getOutput(result));
            }

I used @AfterMethod because i want text to get attached when test ends, whether it passes or fails. I replaced all my System.out.println() with Reporter.log(). As a result, text is getting attached to allure report perfectly fine but not getting printed on console.

Is there any way i can get text on both- console and allure report?

Thanks !!

⇜Krishnan Mahadevan⇝

unread,
Nov 24, 2017, 5:13:59 AM11/24/17
to testng...@googlegroups.com

Use Reporter.log("text", true) the two arg log() method which will cause the text to be printed on the console as well.


--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
--

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

My Technical Scribbings @ http://rationaleemotions.wordpress.com/

garvitag...@gmail.com

unread,
Nov 24, 2017, 5:54:44 AM11/24/17
to testng-users
It worked. Thank you !!

tota...@gmail.com

unread,
Mar 1, 2018, 6:58:04 AM3/1/18
to testng-users
Hi,

Please find the Step-by-Step implementation of Maven,Testng,Allure Reporting with steps.

Thanks,
Reply all
Reply to author
Forward
0 new messages