0
votes

I want to use parameterized tests for TestNG. I have created xml file with parametrs (par.xml). Parametrs are using for method inluded in registration.java.

Is executing only possible by: par.xml -> run as -> TestNG? IF I try to run by class I get error:

org.testng.TestNGException: Parameter 'userEmail' is required by @Test on method testRejestracja but has not been marked @Optional or defined in C:\Users\Sonia\AppData\Local\Temp\testng-eclipse--2102596193\testng-customsuite.xml

Is it possible to avoid test failure? I would like to run all java class to exceute all tests in same time.

1

1 Answers

2
votes

When you annotate a @Test method with the @Parameters annotation, you are essentially telling TestNG that the parameters for your @Test method can be found from the <parameters> tag in the TestNG suite xml file.

But when you attempt at running a class directly (either via your favorite IDE or via a build tool) there is no suite xml file and so TestNG does not know what to provide as values for the parameters of your @Test method.

So you would need to stick to running these methods ONLY via a TestNG suite xml file (or) use @Optional annotation to tell TestNG that incase it doesn't find any values to inject from the <parameters> tag, it should just inject a null value.