Dont know why my tests are skipped.

645 views
Skip to first unread message

Jerald paul

unread,
Nov 19, 2011, 4:51:48 AM11/19/11
to testng...@googlegroups.com
Dont know why my tests are skipped.  Am using selenium webdriver automation tool and testng. Before i used junit and all my tests are ran with out a glitch. I came to testng all because of the better reports. But now most of my tests are skipped and doesnt give me a clue where to look. It just simply adds the test in skipped configurations.

I have a base class and i extend this class for all my tests. This base class have the setup and teardown methods. I badly need a stack trace of my skipped configurations/test/whatever u call it.  I personally regret my decision and i have some 150 + test cases. If some helps me to switch back to junit, i will be happy.

thanks
jerald

Jerald paul

unread,
Nov 19, 2011, 4:56:40 AM11/19/11
to testng...@googlegroups.com
All of my setup and teardown methods are skipped. I have some 150 tests and 60 test are passed and remaining tests are skipped. I dont know what happed while running this test. if anybody knows how to add a stacktrace info for setup and teardown methods i will be happy and appreciate your help.
thanks
jerald

Tomek Kaczanowski

unread,
Nov 19, 2011, 5:02:04 AM11/19/11
to testng...@googlegroups.com
You have numerous ways to monitor what is going on when your tests are
executed. You can check testng-results.xml file, add some
System.out.println in your methods or write custom test listeners. I
would suggest you try to do the first two, and tell us what you see.

And btw. the more details you give, the more precise the answers. :)

--
Regards / Pozdrawiam
Tomek Kaczanowski
http://kaczanowscy.pl/tomek

2011/11/19 Jerald paul <paulj...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups
> "testng-users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/testng-users/-/7tuNAfTPBhcJ.
> To post to this group, send email to testng...@googlegroups.com.
> To unsubscribe from this group, send email to
> testng-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/testng-users?hl=en.
>

syed ameen

unread,
Nov 19, 2011, 5:31:54 AM11/19/11
to testng...@googlegroups.com
My tests are getting skipped when I run the same test in different
browsers. I suspect identifying objects issue but same test is
running some time and getting skipped the other time. Will there be
issue with the webdriver version used? do we have a list of web
drivers that support different versions of browers?

Syed

Jerald paul

unread,
Nov 19, 2011, 5:58:42 AM11/19/11
to testng...@googlegroups.com
Now i have added a try catch inside the setup method and added a Assert.fail with error message as 'failed inside setup method' and now testing this. I also have added a printStackTrace and now i will get a clue where my tests are failing. Am i doing this in a right direction?

Krishnan Mahadevan

unread,
Nov 19, 2011, 6:02:53 AM11/19/11
to testng...@googlegroups.com
Not sure if you do really require Asserts within configuration methods. I guess that a configuration method would be considered to be a failed by TestNG if it throws any exceptions.


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


On Sat, Nov 19, 2011 at 4:28 PM, Jerald paul <paulj...@gmail.com> wrote:
Now i have added a try catch inside the setup method and added a Assert.fail with error message as 'failed inside setup method' and now testing this. I also have added a printStackTrace and now i will get a clue where my tests are failing. Am i doing this in a right direction?

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/fnl-lYG28_oJ.

Jerald paul

unread,
Nov 19, 2011, 8:23:07 AM11/19/11
to testng...@googlegroups.com
So what should i do to find which line of code caused the problem? am using setup method to login to the application.
thnaks
jerald

Cédric Beust ♔

unread,
Nov 19, 2011, 12:25:36 PM11/19/11
to testng...@googlegroups.com
If all your tests are skipped, one of your configuration methods might be failing. Do you see any exception? Are you swallowing any exception? (this would explain why you're not seeing anything wrong)

-- 
Cédric




--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/0a8BP6E09YwJ.

Jerald paul

unread,
Nov 21, 2011, 3:09:33 AM11/21/11
to testng...@googlegroups.com
No am not swallowing any exception. This is my setup method -

@BeforeMethod
    public void setUp() throws Exception
    {
        int waitInSecs = Integer.parseInt(Util.getProperties().getProperty("implicitwait"));
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(waitInSecs, TimeUnit.SECONDS);
        driver.get(Util.getBaseUrl());
    }

And most of my tests(Not all of my tests) are skipped. I wounder why some of my tests are considered for running/executing instead of getting skipped. The report does not have any stack trace/clue to debug.


Thanks & Regards
jerald

Jerald paul

unread,
Nov 21, 2011, 3:11:25 AM11/21/11
to testng...@googlegroups.com
Also i dont find any useful info in the column "instance" in the skipped/passed reports.

Cédric Beust ♔

unread,
Nov 21, 2011, 11:01:02 AM11/21/11
to testng...@googlegroups.com
I see some potential for your @BeforeMethod to be skipped. What happens when you make it an empty method?

Do you have any other @Before* method? At any rate, we can't help you unless you post a small test case showing the problem, and I bet that while trimming down your test case, you'll find the error yourself. Feel free to post it if you don't.

-- 
Cédric





jerald

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/Zl4zRqS7xW4J.

Jerald paul

unread,
Nov 22, 2011, 2:10:46 AM11/22/11
to testng...@googlegroups.com
Hi,
This is my base class


package selenium.resources.tests;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;

import selenium.util.Util;


public class PMPTestCase
{
    public WebDriver driver;

    /*
     * This method will connect to the browser window
     */

    @BeforeMethod
    public void setUp() throws Exception
    {
        int waitInSecs = Integer.parseInt(Util.getProperties().getProperty("implicitwait"));
        driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(waitInSecs, TimeUnit.SECONDS);
        driver.get(Util.getBaseUrl());
    }

    @AfterMethod
    public void tearDown() throws Exception
    {
    driver.quit();
    }
}

-------------------------------------------------------------
This is my test class

package selenium.admin.tests;

import org.openqa.selenium.By;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import selenium.admin.pages.AdminListPage;
import selenium.admin.pages.PasswordPolicyPage;
import selenium.resources.pages.CommonPage;
import selenium.resources.tests.PMPTestCase;
import selenium.util.Util;

public class NonAsciiPasswordPolicy extends PMPTestCase
{
            PasswordPolicyPage page;
            CommonPage cPage;
            AdminListPage aPage;

            @BeforeMethod
            @Override

            public void setUp() throws Exception
            {
                        super.setUp();
                        page = PageFactory.initElements(driver, PasswordPolicyPage.class);
                        cPage = PageFactory.initElements(driver, CommonPage.class);
                        aPage = PageFactory.initElements(driver, AdminListPage.class);
            }

            @Test(description = "Test with extended ascii in password policy name")
            public void TestPasswordPolicy_ExtAsciiForPolicyName() throws Exception
            {
                        // Goto 'Password Policy' page
                        getPasswordPolicyPage();
                        // Enter policy name
                        String name = Util.extAscii + System.currentTimeMillis();
                        page.enterPolicyName(name);
                        // Enter valid valie in min length
                        page.enterMinLength("6");
                        // Enter characters in max length
                        page.enterMaxLength("8");
                        // Click on 'Save' button
                        page.clickSaveBtn(driver);
                        // Check if it is added by searching the list page
                        // Search for the password policy
                        page.searchPP(name, driver);
                        // Get password policy count
                        Util.waitForwebElement(driver, By.cssSelector("img[src$='editicon.gif']"));
                        int uCount2 = driver.findElements(By.cssSelector("img[src$='editicon.gif']")).size();
                        if (uCount2 <= 0)
                        {
                            Assert.fail("Password policy not added sucessfully. Check password policy addition, pp count " + uCount2
                                    + ".Should be atleast one after searching");
                        }
                        //Click on the edit icon
                        page.clickEditIcon();
                        //Get the policy name from the edit page
                        String pName = Util.getSafeString(page.getEditPolicyName().getAttribute("value"));
                //        String pName = Util.getSafeString(page.getEditPolicyName().getAttribute("value"));
                        if(!pName.equals(name))
                        {
                                    Assert.fail("Password policy not added properly. Expected password policy name '"+name+"' but actual value '"+pName+"'");
                        }
            }

            @Test(description = "Test with extended ascii in password policy name")
            public void TestPasswordPolicy_Utf8ForPolicyName() throws Exception
            {
                        // Goto 'Password Policy' page
                        getPasswordPolicyPage();
                        // Enter policy name
                        String name = Util.utf8 + System.currentTimeMillis();
                        page.enterPolicyName(name);
                        // Enter valid valie in min length
                        page.enterMinLength("6");
                        // Enter characters in max length
                        page.enterMaxLength("8");
                        // Click on 'Save' button
                        page.clickSaveBtn(driver);
                        // Check if it is added by searching the list page
                        // Search for the password policy
                        page.searchPP(name, driver);
                        // Get password policy count
                        Util.waitForwebElement(driver, By.cssSelector("img[src$='editicon.gif']"));
                        int uCount2 = driver.findElements(By.cssSelector("img[src$='editicon.gif']")).size();
                        if (uCount2 <= 0)
                        {
                                    Assert.fail("Password policy not added sucessfully. Check password policy addition, pp count " + uCount2
                                            + ".Should be atleast one after searching");
                        }
                        //Click on the edit icon
                        page.clickEditIcon();
                        //Get the policy name from the edit page
                //        String pName = Util.getSafeString(page.getEditPolicyName().getAttribute("value"));
                        String pName = Util.getSafeString(page.getEditPolicyName().getAttribute("value"));
                        if(!pName.equals(name))
                        {
                                    Assert.fail("Password policy not added properly. Expected password policy name '"+name+"' but actual value '"+pName+"'");
                        }
            }

            private void getPasswordPolicyPage() throws Exception
            {
                        //Login to PMP
                        Util.login(driver);
                        // Click on admin tab
                        cPage.clickAdminTabLink(driver);
                        // Click on users link
                        aPage.clickPPSettings(driver);
                        // Click o=n 'Add Policy' btn
                        page.clickAddPolicyBtn();
                        // Check add users page
                        page.checkPasswordPolicyPageElements(driver);
            }
}




As u said i will remove my codes inside the setup methods and try running it. I hope this solution will work for me. Thank you Cédric.

Regards
Jerald

Cédric Beust ♔

unread,
Nov 22, 2011, 2:32:43 AM11/22/11
to testng...@googlegroups.com
What I suggested will simply point out that there is a bug in your before method. Inspect the stack trace, you should figure it out right away.

-- 
Cédric






Regards
Jerald

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/testng-users/-/bl4R_SthO94J.
Reply all
Reply to author
Forward
0 new messages