TestNG Groups and BeanShell

343 views
Skip to first unread message

ponto

unread,
Apr 13, 2010, 11:41:32 AM4/13/10
to testng-users
If we have <include name="web" > and <include name="weekend" >, TestNG
runs all the methods that belong to either web or weekend. I was
looking for a way to change this behaviour so TestNG would run all the
methods that belong to web and weekend. I tried to use beanshell
inside my testng's xml.
i ended up using this piece of code:

<script language="beanshell"><![CDATA[
test = method.getAnnotation(org.testng.annotations.Test.class);
if (test != null) {
groups = ((org.testng.annotations.Test)test).groups();
for (int i = 0; i < groups.length; i++) {
if (groups[i].equals("pesquisa")) {
return true;
}
}
}
return false;
]]>
</script>


Looking at testng's output it was filtering, but i don't know why it
was no running my @BeforeTest methods.

Do you know how to solve this?

Many thanks

Cédric Beust ♔

unread,
Apr 13, 2010, 12:16:36 PM4/13/10
to testng...@googlegroups.com
Is your @BeforeTest method part of this group as well?  (also, are you sure you mean @BeforeTest and not @BeforeMethod?)

-- 
Cédric



--
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édric


ponto

unread,
Apr 13, 2010, 12:27:56 PM4/13/10
to testng...@googlegroups.com
I thought that so i change my beanshell condition to a two parts decision: one for beforemethods where i compare them to a group "setup" and the other part for the test method itself. something like:
(groups.containsKey("group1") && groups.containsKey("group2")) || ( groups.containsKey("setup") && (groups.containsKey("group1"))

beanshell integration is an excellent functionality.

keep the good work!

2010/4/13 Cédric Beust ♔ <cbe...@google.com>
Reply all
Reply to author
Forward
0 new messages