@Test(singleThreaded = true, groups = {"L3"})public class MyTest {...}
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
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.
C:>mvn test -test=TestAfterClass -Dgroups=L3-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
In ctor(): RC_DEFAULT
In myFactory(): RC_DEFAULT
In ctor(): RC_DEFAULT
In initResources(): RC_ZERO
In ctor(): RC_DEFAULT
In initResources(): RC_ONE
In runBefore(): RC_ZERO
In testCaseOne(): RC_ZERO
In runAfter(): RC_ZERO
In runBefore(): RC_ONE
In testCaseOne(): RC_ONE
In runAfter(): RC_ONE
Tests run: 4, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0.436 secResults :Tests run: 4, Failures: 0, Errors: 0, Skipped: 2
C:>mvn test -test=TestAfterClass -Dgroups=L1-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
In ctor(): RC_DEFAULT
In myFactory(): RC_DEFAULT
In ctor(): RC_DEFAULT
In initResources(): RC_ZERO
In ctor(): RC_DEFAULT
In initResources(): RC_ONE
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.46 sec
There are no tests to run.Results :Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
Thanks for the clarification.My @Factory is currently defined in my base class but the groups are being defined on the subclass so @Factory(groups = ... ) won't help in my case.
As an alternative, what if TestNG checks the parent class containing the @Factory. If it has 'groups' defined, but doesn't have a matching group then skip running @Factory? (I haven't thought through this in any depth).
--
You received this message because you are subscribed to the Google Groups "testng-users" group.
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.
Because it is boiler plate code that doesn't change currently between test classes. I don't want to duplicate it.
Because it is boiler plate code that doesn't change currently between test classes. I don't want to duplicate it.
None of my test classes run without first being created and initialized through the factory. The factory sets up the Selenium instances, determines which test environment (base URL, languages, type of browser to use , etc.) to use and creates the test class instances based on that information.
I don't want to do all that work if the class is excluded because it is part of a different group.
That won't change the issue... I still need to either 1) only run the @Factory for classes that have the correct group defined, or 2) manually use ITestContext to do limit test instance creation based on the defined groups.
As you pointed out, option 2) can be done now but requires me to deviate from native TestNG behavior.
I'm simply wondering if TestNG could be enhanced to do for @Factories at the class level, what it already does for class level @Test annotations.
"For before methods (beforeSuite, beforeTest, beforeTestClass and beforeTestMethod, but not beforeGroups): If set to true, this configuration method will be run regardless of what groups it belongs to.For after methods (afterSuite, afterClass, ...): If set to true, this configuration method will be run even if one or more methods invoked previously failed or was skipped." (See TestNG Annotations)