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?:)