How to customize TestNG report based on Group instead of @Test?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to customize TestNG report based on Group instead of @Test?

Hoang Nguyen
Hi all,

I'm facing one issue about customization TestNG report

One TestCase in my scenario is defined by a group, not a @Test (it can include many @Test)

@Test(groups = {"Test00"})
public class Test00
{
    WebDriver Chrome2;

    Customer_Common Customer_Common_Chrome2;
    Customer_Login Customer_Login_Chrome2;
    @Test(alwaysRun = false)
    protected void AAsetUp() throws Exception
    {
        System.setProperty("webdriver.chrome.driver", "D:\\AutoTest\\Java\\WebDriver\\chromedriver.exe");
    }
    @Test(alwaysRun = false)
    protected void GoToURL() throws Exception
    {
        ....
    }
    @Test(alwaysRun = false)
    protected void Login() throws Exception
    {
        ....
    }
}

Currently the report is show there are 3 tests, because it count based on annotation @Test
My expectation is the report should recognize 1 test.
Any other way to count Test based on Group instead of @Test?

Many thanks,
Hoang

--
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
|  
Report Content as Inappropriate

Re: How to customize TestNG report based on Group instead of @Test?

Hoang Nguyen
another thing:
By default TestNG and JUnit treat a annotation @Test is a Test Case
How to custom to treat a Class is a Test Case (instead of annotation @Test). It need for the report correctly.

--
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
|  
Report Content as Inappropriate

Re: How to customize TestNG report based on Group instead of @Test?

Krishnan Mahadevan
In reply to this post by Hoang Nguyen

Hoang,

 

If you would like to group two or more @Test methods based on the group to which they belong to, then you would need to build the reporting mechanism on your own. I don’t think there are any reporters that are out there, which gives you this grouping out of the box.

 

You would start off by building an implementation of IReporter wherein you build both the logical grouping based on group names and also the view part of it.

 

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/

 

From: <[hidden email]> on behalf of Hoang Nguyen <[hidden email]>
Reply-To: <[hidden email]>
Date: Thursday, May 18, 2017 at 9:01 AM
To: testng-users <[hidden email]>
Subject: [testng-users] How to customize TestNG report based on Group instead of @Test?

 

Hi all,

 

I'm facing one issue about customization TestNG report

 

One TestCase in my scenario is defined by a group, not a @Test (it can include many @Test)

 

@Test(groups = {"Test00"})

public class Test00

{

    WebDriver Chrome2;

 

    Customer_Common Customer_Common_Chrome2;

    Customer_Login Customer_Login_Chrome2;

    @Test(alwaysRun = false)

    protected void AAsetUp() throws Exception

    {

        System.setProperty("webdriver.chrome.driver", "D:\\AutoTest\\Java\\WebDriver\\chromedriver.exe");

    }

    @Test(alwaysRun = false)

    protected void GoToURL() throws Exception

    {

        ....

    }

    @Test(alwaysRun = false)

    protected void Login() throws Exception

    {

        ....

    }

}

 
Currently the report is show there are 3 tests, because it count based on annotation @Test
My expectation is the report should recognize 1 test.
Any other way to count Test based on Group instead of @Test?
 

Many thanks,

Hoang

--
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.

--
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
|  
Report Content as Inappropriate

Re: How to customize TestNG report based on Group instead of @Test?

Krishnan Mahadevan
In reply to this post by Hoang Nguyen

Hoang,

 

TestNG by default recognizes the small unit of work (a testcase) as a method that is annotated using @Test annotation.

 

So if you would like TestNG to treat a class as a Test case (a class which houses one or more @Test annotated methods ), then again, you would need to build this on your own in an org.testng.IReporter implementation. I don’t think there’s any reporter implementation out there which can do this for you.

 

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/

 

From: <[hidden email]> on behalf of Hoang Nguyen <[hidden email]>
Reply-To: <[hidden email]>
Date: Thursday, May 18, 2017 at 4:08 PM
To: testng-users <[hidden email]>
Subject: [testng-users] Re: How to customize TestNG report based on Group instead of @Test?

 

another thing:

By default TestNG and JUnit treat a annotation @Test is a Test Case

How to custom to treat a Class is a Test Case (instead of annotation @Test). It need for the report correctly.

--
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.

--
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
|  
Report Content as Inappropriate

Re: How to customize TestNG report based on Group instead of @Test?

Hoang Nguyen
Hi Krishnan,

That's is my bad while using a lot of @Test in one TestCase 
I've replaced some @Test with @BeforeMethod and @AfterMethod(alwaysRun = false)

package TestLab.May.May18th.Test_Chrome;

import Libs.Utils.*;
import FrameWork.*;
import Libs.Customer.*;
import Libs.CustomerPayments.*;
import Libs.AdminDev.*;
import Libs.WebMail.*;
import Libs.ComData.*;
import Libs.WinApp.*;
import Libs.Appium.*;
import autoitx4java.AutoItX;
import org.openqa.selenium.WebDriver;
import io.appium.java_client.remote.MobileCapabilityType;
import org.testng.annotations.*;
import org.sikuli.script.*;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.chrome.ChromeDriver;

@Test(groups = {"Test00"})
public class Test00
{
WebDriver Chrome2;

Customer_Common Customer_Common_Chrome2;
Customer_Login Customer_Login_Chrome2;
@BeforeMethod(alwaysRun = false)
protected void AAsetUp() throws Exception
{
System.setProperty("webdriver.chrome.driver", "D:\\AutoTest\\Java\\WebDriver\\chromedriver.exe");
Utils.loadJacobLibraries();
AutoItX autoIT_Chrome2 = new AutoItX();
Map<String, Object> plugin_Chrome2 = new HashMap<String, Object>();
plugin_Chrome2.put("enabled", false);
plugin_Chrome2.put("name", "Chrome PDF Viewer");
Map<String, Object> prefs_Chrome2 = new HashMap<String, Object>();
prefs_Chrome2.put("download.default_directory","D:\\AutoTest\\TestData\\Files\\Download");;
prefs_Chrome2.put("profile.default_content_settings.popups", 0);
prefs_Chrome2.put("plugins.plugins_list", Arrays.asList(plugin_Chrome2));
prefs_Chrome2.put("credentials_enable_service", false);
prefs_Chrome2.put("profile.password_manager_enabled", false);
DesiredCapabilities caps_Chrome2 = DesiredCapabilities.chrome();
ChromeOptions options_Chrome2 = new ChromeOptions();
options_Chrome2.setExperimentalOption("prefs", prefs_Chrome2);
options_Chrome2.addArguments("start-maximized");
options_Chrome2.addArguments("disable-infobars");
caps_Chrome2.setCapability(ChromeOptions.CAPABILITY, options_Chrome2);
caps_Chrome2.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
Chrome2 = new ChromeDriver(caps_Chrome2);
Buffer.Add("Chrome2",autoIT_Chrome2.winGetHandle("data:, - Google Chrome"));

Customer_Common_Chrome2 = new Customer_Common(Chrome2);
Customer_Login_Chrome2 = new Customer_Login(Chrome2);
}
@Test(alwaysRun = false)
public void Test00() throws Exception
{
Utils.RearrangeTCResultsLogFile("D:\\AutoTest\\TestScriptsRepository\\TestLab\\May\\May18th\\Results\\Test_Chrome\\Test00");

Customer_Common_Chrome2.LaunchBrowser("https://mail.google.com");
Customer_Login_Chrome2.Login("[hidden email]", "Password", "true", "null");

}
@AfterMethod(alwaysRun = true)
protected void ZZCleanUP_1() throws Exception
{
Utils.CleanUp();
Customer_Login_Chrome2.Logout();
}
@AfterMethod(alwaysRun = true)
protected void ZZCleanUP_2() throws Exception
{
Utils.CleanUp();
Customer_Common_Chrome2.CloseBrowser();
}
}

Vào 22:55:26 UTC+7 Thứ Năm, ngày 18 tháng 5 năm 2017, Krishnan đã viết:

Hoang,

 

TestNG by default recognizes the small unit of work (a testcase) as a method that is annotated using @Test annotation.

 

So if you would like TestNG to treat a class as a Test case (a class which houses one or more @Test annotated methods ), then again, you would need to build this on your own in an org.testng.IReporter implementation. I don’t think there’s any reporter implementation out there which can do this for you.

 

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/

 

From: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3tTxekQ1AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...> on behalf of Hoang Nguyen <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3tTxekQ1AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">tind...@...>
Reply-To: <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3tTxekQ1AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Date: Thursday, May 18, 2017 at 4:08 PM
To: testng-users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="3tTxekQ1AQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@...>
Subject: [testng-users] Re: How to customize TestNG report based on Group instead of @Test?

 

another thing:

By default TestNG and JUnit treat a annotation @Test is a Test Case

How to custom to treat a Class is a Test Case (instead of annotation @Test). It need for the report correctly.

--
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="3tTxekQ1AQAJ" 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="3tTxekQ1AQAJ" 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.

--
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.
Loading...