views:

162

answers:

2

If we have <include name="web" > and <include name="weekend" >, TestNG runs all the methods that belong to either web or weekend.

Is it possible to change this behaviour so TestNG would run all the methods that belong to web and weekend? Does anyone knows a way to accomplish this?

+2  A: 

i've found a solution.

i used beanshell to script my conditions inside the <method-selector> tag.

something like:

 <method-selectors>
    <method-selector>
      <script language="beanshell"><![CDATA[
        (groups.containsKey(FIRST_GROUP) && groups.containsKey(SECOND_GROUP)) 
           ]]>
        </script>
     </method-selector>
    </method-selectors>
the qwerty
+2  A: 

Yes, BeanShell is one approach.

If you need something more sophisticated, you can use an IMethodInterceptor, which basically lets you reorder all the test methods before TestNG starts processing them.

Here is an example:

http://beust.com/weblog/2008/03/29/test-method-priorities-in-testng/

Cedric Beust