Question

I am trying to run a TestNG test which has a login method . I am passing the parameters at @ Test and also in testng.xml The login test passes if I run it as a Testsuite but if I run the test case as testNG test it fails and gives me the below error: org.testng.TestNGException: Parameter 'Username' is required by @Test on method loginTest but has not been marked @Optional or defined in C:\\AppData\Local\Temp\testng-eclipse--1466657283\testng-customsuite.xml

My testng.xml is in the same workspace as the current project.

Was it helpful?

Solution

You might be specifying the username as a parameter in your suite xml. When you run as suite, that particular xml is used. But when you select a single test and run it, testng creates a custom testng file (with bare minimums - no parameters, no listeners - you can take a look at the file on the path that you mention).

You need to specify your xml as a template xml in eclipse if that is a standard xml that you use. Go to project properties -> testng -> Set the xml as a template xml.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top