I have always getting this error for test tag (at line test name="Bing-Search-Sample...) in TestNG XML configuration file, when eclipse is trying to validate the XML against its DTD. The file is working fine and seems to have no problems:
The content of element type "test" must match "(method-selectors?,parameter*,groups?,packages?,classes?)".
XML File:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="tests" allow-return-values="true"
verbose="10">
<test name="Bing-Search-Sample-Test">
<classes>
<class name="package.TestFactory" />
</classes>
<groups>
<run>
<include name="sample-tests" />
</run>
</groups>
<parameter name="testInterfaceXML" value="SearchInterface.xml"></parameter>
<parameter name="testSuiteXML" value="SearchTest.xml"></parameter>
</test>
</suite>
Since the XML is working fine, I am wondering if there is a problem with TestNG DTD or in the XML file validation with eclipse.
Apparently the order of the elements are important. First comes the parameters, then groups, and classes should be the last element in the test element. That's the correct format of configuration file:
<suite name="tests" allow-return-values="true"
verbose="10">
<test name="Bing-Search-Sample-Test">
<parameter name="testInterfaceXML" value="SearchInterface.xml"></parameter>
<parameter name="testSuiteXML" value="SearchTest.xml"></parameter>
<groups>
<run>
<include name="sample-tests" />
</run>
</groups>
<classes>
<class name="package.TestFactory" />
</classes>
</test>
</suite>