1

Here is my testng.xml:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="com.mycompany.app_maven-project_jar_1.0-SNAPSHOT">
    <suite-files>
        <suite-file path="src/main/resources/testng.xml" />
    </suite-files>
    <test name="Regression Tests">
        <parameter name="username" value="rashRodeo"/>
        <parameter name="password" value="rashRodeo@1234"/>
        <classes>
            <class name="com.maven.regressionTwo.functionalTwo.TestNGTestsTwo">
             <methods>
                 <exclude name="enterSearchTextDTWO" />                     
             </methods>
            </class>
        </classes>
    </test>
</suite>

here is my @Test using the parameters above:

@Test
@Parameters ({"username","password"})
public void checkForParameters(String username, String password) {

       System.out.println("Username is :"+username+ " Password is: "+password);

}

what is wrong here, why it is getting skipped?

3

I think you have to use proper TestNg annotations sequence-

Like this-

@Parameters ({"username","password"})
@Test
public void checkForParameters(String username, String password) 
{

       System.out.println("Username is :"+username+ " Password is: "+password);

}

It should works ......

0

If you give the following in the xml it works:

    <suite-file path="./testng.xml" />   

What exactly is the error message you get?

  • There is no error, the Test using @Parameters is just skipped. Even doing this change did not help. – Sukhvinder Nov 13 '15 at 11:17
  • Sorry here is the error: Parameter 'username' is required by Test on method printParametersFromTestNGXML but has not been marked Optional or defined – Sukhvinder Nov 13 '15 at 11:55
  • D you have another method called printParametersFromTestNGXML( )? Your checkForParameters( ) method is fine- printParametersFromTestNGXML( ) is where you need to correct parameter sequence. – demouser123 Nov 13 '15 at 12:11
  • Sorry I just renamed the method hence the confusion – Sukhvinder Nov 13 '15 at 12:17
  • 1
    Figured it out, was using NetBeans IDE which was not running testng.xml as TestSuite – Sukhvinder Nov 18 '15 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.