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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

garvitagirotraev
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 !!

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

⇜Krishnan Mahadevan⇝

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


On Fri, Nov 24, 2017, 15:31 <[hidden email]> wrote:
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 !!

--
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 [hidden email].
To post to this group, send email to [hidden email].
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/

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

garvitagirotraev
It worked. Thank you !!

On Friday, November 24, 2017 at 3:43:59 PM UTC+5:30, Krishnan Mahadevan wrote:

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


On Fri, Nov 24, 2017, 15:31 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QUxn0OoAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">garvitag...@...> wrote:
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 !!

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QUxn0OoAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="7QUxn0OoAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">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 @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/

My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

--
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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.