Question

Im having the following problem, When i run a testng suite, I get the following error:

"Parameter 'paramName' is required by @ test on method testMethod, but has no been marked @OPtional o or defined". The problem that everything is correct here is part of the code im trying to execute:

  <test name = "Test name">
    <parameter name="model" value="bank"/>
    <parameter name="module" value="buyer"/>
    <parameter name="testName" value="testname" />
    <classes>           
        <class name="com.company.test.cases.example">
            <methods>
                <include name = "testMethod">
                    <parameter name="testLinkName" value="NAme on testlink to report to."/>
                </include>
            </methods>
        </class>
    </classes>
</test> 


@Parameters({"model", "module", "testName", "testLinkName"})
@Test
public void testMethod(String model, String module, String testName, String testLinkName) throws Exception {
    homePage = new HomePage(getDriver());
    homePage.navigateToBank();
    securityPage = new BankSecurity(this);
    securityPage.validateBankUI();
    assertTest(securityPage);
}

Were this test is, extends from base Test which has the following method invoked before the test

   @Parameters({"model", "module", "testName", "testLinkName"})
@BeforeMethod
public void beforeTest(String model, String module, String testName, String testLinkName)
{
    this.subModel=model;
    this.moduleName = module;
    this.testName = testName;
    this.testLinkName = testLinkName;
}

I'm not including were the driver is instantiated. If any could have any idea of what could be happening.

Was it helpful?

Solution

I was able to access the parameter succesfully. Try moving the parameter out in the methods tag.

<test name="OfferTests" >
    <parameter name="and" value="1"></parameter>
    <classes>
       <class name="com.nv.tests" >
        <methods>
            <parameter name="abc" value="def"></parameter>
            <include name="test1"></include>
        </methods>
       </class> 
    </classes>
  </test>

Test method is

@Parameters({"and","abc"})
    @Test
    public void test1(String b, String a){
        System.out.println(b+a);
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top