temp-testng-customsuite.xml and @Optional

575 views
Skip to first unread message

Pavel Georgiev

unread,
Jul 28, 2008, 6:37:30 PM7/28/08
to testng-users
Hi,

I use the @Optional annotation to execute my tests from Eclipse.
However i face the following issue.

This is a sample code:

---- snip ----

@Parameters( { "test.section" })
@BeforeTest
public void setHostname(@Optional("default")String testSection)
throws IOException {

System.out.println(testSection)

}

@Test
public void test() {
System.out.println("TEST");
}
---- snip ----

If i rigth-click on the class and execute it as TestNG test the plugin
creates the following xml file to execute the class (the xxx are the
package names):

--- temp-testng-customsuite.xml ---

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="MFT Functional Tests">
<parameter name="test.section" value="not-found"/>
<test verbose="2" name="xxx.xxx.xx.xx.x.x.x.x.x.x.xxx.Dummy"
annotations="JDK">
<classes>
<class name="xxx.xxxx.xxx.xx.xxx.xx.Dummy"/>
</classes>
</test>
</suite>
-------------------------------------------------

Notice the value in the <parameter> section - "not-found". This means
that the testSection variable is not assigned correctly. Instead of
"default" it is assigned "not-found". However, if i execute the test
itself by right-clicking on it TestNG generates the following xml
file:

-------- temp-testng-customsuite.xml -------

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="MFT Functional Tests">
<test verbose="2" name="xxx.x..x.x.x.x..x.x.x.x.Dummy"
annotations="JDK">
<classes>
<class name=xx.x.x.x..x.x.x..x.x..x.x.x..Dummy">
<methods>
<include name="runTest"/>
</methods>
</class>
</classes>
</test>
</suite>

-------------------

Now the <parameter> part is missing and the testSection variable is
initialized correctly (it is assigned "default").

I'm using the latest Eclipse plugin (5.8.0.2). I assume this is a bug
in the plugin, right?:)

gemz

unread,
Jul 29, 2008, 1:12:57 PM7/29/08
to testng-users
Try this:(give test first and parameters next)

@BeforeTest
@Parameters( { "test.section" })



On Jul 28, 6:37 pm, Pavel Georgiev <pavel.vasilev.georg...@gmail.com>
wrote:

Pavel Georgiev

unread,
Jul 30, 2008, 1:45:48 PM7/30/08
to testng-users
Yep. It works:)))))))))

Thanks.
Reply all
Reply to author
Forward
0 new messages