Discussion:
BeforeSuite runs only one test class
Jai P
2011-06-27 20:44:29 UTC
Permalink
If I have two classes as part of my test in the suite, BeforeSuite
runs only the second one and gives NullPointerException for all tests
in the first test class despite specifying preserve-order="true"

I have the following testng.xml

<test name="ReportingTests" preserve-order="true">
<classes>
<class name="com.blah.ReportRunTests">
<methods>
<include name="login" />
<include name="checkHomeTab" />
<include name="checkReportsTab" />
<include name="checkReportsExist" />
<include name="reportsCleanup" />
</methods>
</class>

<class name="com.blah.ActivityTests">
<methods>
<include name="login" />
<include name="checkHomeTab" />
<include name="checkReportsTab" />
<include name="checkReportsExist" />
<include name="expandReportsTabAndClickActivity" />
</methods>
</class>
</classes>

My Test class has this:

@Parameters({ "webconsoleStartupURL" })
@BeforeSuite(description = "Perform class setup tasks")
public void beforeClass(final String webconsoleStartupURL)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException {
sm = new SeleniumMgr(webconsoleStartupURL);
sm.startSelenium();
}

@AfterSuite(description = "Perform class teardown tasks")
public void afterClass() {
sm.stopSelenium();
}

When i execute the tests, only the second test in the xml,
i.e.ActivityTests seems to run and then it exits the suite. The first
class in not executed and I see NullPointerException for each of the
tests in the first.

I want only one instance of the browser and have multiple tests
executed. The testng doc suggests the xml version I have used above is
in fact correct. What is wrong here?
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to testng-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Cédric Beust ♔
2011-06-28 00:22:43 UTC
Permalink
@BeforeSuite should run once, and only once, before any test starts.

If you are seeing something different, please create a small project that I
can build, zip it up and email it to me.

Thanks.
--
Cédric
Post by Jai P
If I have two classes as part of my test in the suite, BeforeSuite
runs only the second one and gives NullPointerException for all tests
in the first test class despite specifying preserve-order="true"
I have the following testng.xml
<test name="ReportingTests" preserve-order="true">
<classes>
<class name="com.blah.ReportRunTests">
<methods>
<include name="login" />
<include name="checkHomeTab" />
<include name="checkReportsTab" />
<include name="checkReportsExist" />
<include name="reportsCleanup" />
</methods>
</class>
<class name="com.blah.ActivityTests">
<methods>
<include name="login" />
<include name="checkHomeTab" />
<include name="checkReportsTab" />
<include name="checkReportsExist" />
<include name="expandReportsTabAndClickActivity" />
</methods>
</class>
</classes>
@Parameters({ "webconsoleStartupURL" })
@BeforeSuite(description = "Perform class setup tasks")
public void beforeClass(final String webconsoleStartupURL)
throws ClassNotFoundException, InstantiationException,
IllegalAccessException {
sm = new SeleniumMgr(webconsoleStartupURL);
sm.startSelenium();
}
@AfterSuite(description = "Perform class teardown tasks")
public void afterClass() {
sm.stopSelenium();
}
When i execute the tests, only the second test in the xml,
i.e.ActivityTests seems to run and then it exits the suite. The first
class in not executed and I see NullPointerException for each of the
tests in the first.
I want only one instance of the browser and have multiple tests
executed. The testng doc suggests the xml version I have used above is
in fact correct. What is wrong here?
--
You received this message because you are subscribed to the Google Groups
"testng-users" group.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/testng-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
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.
Tarun K
2011-06-28 08:23:57 UTC
Permalink
Are you sure you have annonated your class - "ReportRunTests" with test tag?
Or if you are using groups than class - "ReportRunTests" belongs to group?

You might consider posting your classes here, provided they are not very
long

~tarun
http://seleniumsoftwaretesting.blogspot.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/-/Ian-exQFzQoJ.
To post to this group, send email to testng-users-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
To unsubscribe from this group, send email to testng-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.
Loading...