0

I am performing unit testing using TestNG where I am testing my code using test cases defined in xml file.

I am performing login operation using the test case defined in xml file. But the catch is I want to send parameter as usersname and password in method login.

Is it possible to pass value(username and password) to login method in xml file where testcases are executed?

Following is my XML file

<suite name="Suite" parallel="none">
  <test name="Test">
    <classes>
      <class name="com.common.Login">
        <methods>
          <include name="login"/>
        </methods>
      </class>
      <class name="com.tmp.Documentrepository"/>
    </classes>
  </test>
</suite>

Thanks

1

1 Answer 1

1

yes , you can send.

testNg file:

<suite name="API TEST CASES">


 <parameter name="userNmae" value="Raghav"/> 
  <parameter name="password" value="password"/> 

<test name="api test" parallel="methods">

    <groups>

        <run>
            <include name="test_proxy" />
        </run>

    </groups>

    <classes>
        <class name="com.spire.test.test" />
    </classes>

</test>


</suite>

Java class:

import org.testng.annotations.Parameters;
import org.testng.annotations.Test;

public class test {
@Parameters({ "userNmae" ,"password"})
@Test(groups = { "test_proxy" })
public void test_proxy(String userNmae,String password) throws Exception {

    System.out.println(userNmae);
    System.out.println(password);

}

}

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.