The Annotations @Parameters is disallowed for this location

2k views Asked by At

I have tried to pass the parametersto test methods.

test.xml file look like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="paramsuite">
  <test name="paramtest">
<parameter name="a" value="SAI"/>
    <classes>
      <class  name="parameterization.ParamExample"></class>
    </classes>
  </test>
</suite> <!-- Suite -->

my class file look like ParamExample.java

package parameterization;

import org.testng.annotations.Test;

import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;

public class ParamExample {
    
    @Parameters("a")
    @Test
    public void stName(String p) {
        
        System.out.println("Student Name is  :"+p);

    }

I am getting error 'The Annotations @Parameters is disallowed for this location'

1

There are 1 answers

0
Shweta Sawaldesai On

You have imported the wrong packages.

import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters;

Use packages from here https://www.javatpoint.com/testng-parameters

import org.testng.annotations.Parameters;