Reputation: 231
There are couple of thread regarding same error but they are not active ,I think last they were active was around 1 yr back so I am opening the new thread .
Testng.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" verbose="1">
<parameter name="google" value="http://www.ezeego1.co.in/" />
<test name="Test">
<classes>
<class name="selenium.karma.bu.DriverApp" />
<class name="selenium.karma.bu.ReadSuite" />
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
DriverApp.java:-
public class DriverApp {
public static WebDriver driver;
@Parameters("google")
@BeforeSuite
public void setUp(String appUrl) throws Exception{
ProfilesIni prof = new ProfilesIni();
FirefoxProfile p = prof.getProfile("default");
p.setPreference("extensions.headertool.preferencies.editor", "sm_universalid: swkv8851\nftusergivenname: vidushi \nftusersn: shukla\nftapplicationroles: Admin\nftusercredentials: ES,PL\n\n");;
p.setPreference("extensions.headertool.preferencies.onoff", true);
driver = new FirefoxDriver(p);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.get("http://10.171.23.218:3080/karmaGui/karmaGui/KarmaGui.html?locale=en#Main") ;
Thread.sleep(5000);
driver.manage().window().maximize();
}
And we have extended it to another java class readsuite.java.
When I execute my ReadSuite.java with testng I get following error:-
Total Rows Accross the sheets : 0
FAILED CONFIGURATION: @BeforeSuite setUp
org.testng.TestNGException:
Parameter 'google' is required by @Configuration on method setUp but has not been marked @Optional or defined
in C:\Users\swkv8851\AppData\Local\Temp\testng-eclipse--1721497351\testng-customsuite.xml
at org.testng.internal.Parameters.createParameters(Parameters.java:155)
at org.testng.internal.Parameters.createParameters(Parameters.java:358)
at org.testng.internal.Parameters.createConfigurationParameters(Parameters.java:86)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:199)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:138)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:277)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
here
C:\Users\swkv8851\AppData\Local\Temp\testng-eclipse--172149735enter code here
1\testng-customsuite.xml get created at run time and it contents are
<suite name="Default suite">
<test verbose="2" name="Default test">
<classes>
<class name="selenium.karma.bu.ReadSuite" />
</classes>
</test>
<!-- Default test -->
</suite>
<!-- Default suite -->
Please help me identifying the error.
When I comment @parameter and @Beforesuite in driverapp.java I do not get this error but then my browser is not invoked.
Upvotes: 3
Views: 18955
Reputation: 11
Though it seems to be a very old post, I am sharing the solution which worked for me.
Basically it requires two settings for TestNG Run 'Class' and 'Suite'
To set the TestNG Run 'Class'
Step1: Goto Project => Run As => Run Configurations => 'Test' tab
Step2: Check option 'Class'. It should be the set with desired '.java' file.
e.g. 'functionalTestCases.java' is on package 'testCases' then 'Class' will be set as 'testCases.functionalTestCases.java'
Step3: Verify the 'Name' field.
e.g It can be 'functionalTC'
Step4: Save the changes using 'Apply' button
To set the TestNG Run 'Suite'
Step1: Goto Project => Run As => Run Configurations => 'Test' tab
Step2: Check option 'Suite'. It should be the set with desired 'testng.xml' file path.
Step3: Verify the 'Name' field.
e.g It can be 'projectname_testng.xml'
Step4: Save the changes using 'Apply' button
After these setting are saved properly, then Run the project with 'projectname_testng.xml'
Also, I am using TestNG annotation as '@BeforeClass' for the method (which refers and checks the 'parameter' passed from 'testng.xml') in 'testCases.functionalTestCases.java'
Upvotes: 1
Reputation: 21
This is probably due to running as @Test. You need to run it at Suite Level
Upvotes: 0
Reputation: 8531
If you want to run only your suite xml file, you need to select your suite file and select Run As-> TestNG Suite.
However, if you want to select a particular test and use the non test part of your suite file i.e. the suite/listeners/parameters section, then you can set this file as a template xml by going to Project Properties->TestNG -> Template XML File (give absolute path of your testng xml here)
Upvotes: 1
Reputation: 3628
It seems that TestNG created the testng.xml programatically because it can't find your testng.xml or you ran your project as a TestNG Test instead of your testng.xml file.
Upvotes: 1