I am using Webdriver + Java + TEstNG + Eclipse.
I have one class = yclassTest 2 method in this class. yclasstestm1 yclasstestm2 I want to execute only one method, and skip the 2nd method (control via testng.xml) My project C:\Documents and Settings\Ma\workspace1\myproj I placed my testng.xml file in the project folder (myproj). Except placing in that folder, I did not do anything else. I was able to Rightclick-> Run As - TestNG Test. But, it seems, test run is not at all controlled by testng.xml. Am I missing anything - Please advise. ---------------------- testng.XML --------------------------------------- <suite name="My test suite"> <test name="testing"> <classes> <class name="y.yclassTest"> <methods> <include name="yclasstestm1"/> </methods> </class> </classes> </test> </suite> --------------------------------------- |
Administrator
|
I suppose you did not configure testng eclipse plugin to use your testng.xml file. Hence it considers all the methods in your test class. Refer this for configuration -
http://testng.org/doc/eclipse.html#eclipse-create-launch After browsing your project, select suite radio button > pick up your testng.xml and you are all set.
~ seleniumtests.com
|
err2.JPG
After placed the testng.xml in my project, and after selected the radio button SUITE (in the configuration), I see the error "Suite file not specified". Please advise. |
Administrator
|
Because you selected "suite" radio button but specified the class. If you want to run class then select class radio button
else select suite radio button and browser suite file.
~ seleniumtests.com
|
This post was updated on .
Thanks for your quick reply!
I placed the xml inside the project folder testnglocation.JPG. After ran the test, got one error. error12.JPG Tried to create a new Run configuration settings -disabledoption.JPG And the field is seen disabled. Sorry for this bunch of questions. My guess is that, I did not put the XML in proper place. I attached testng plugin - org.testng.feature_5.9.0.4.JAR In Eclipse->Install Software - added the URL "http://beust.com/eclipse", and finished the downloads. I am not sure whether this is really required or not. Any advice? |
Administrator
|
Location of testng.xml looks right.
Let's see the disabled issue first. Is Browse button next to suite text box also disabled? If not can you use it to browse the testng.xml file?
~ seleniumtests.com
|
When clicked Class radio button, I was able to get a popup in which I could see the existing classes. enabledPackage.JPG
But, when I selected Suite radio, the Browse button is disabled. Means, though not LITERALLY disabled, it did not return any popup windows with some values. Should I have a TestNG class (I have only Java classes) to achieve this? Do u think this xml is valid, (though I validated in browser) : <suite name="My test suite"> <test name="testing"> <classes> <class name="pack1.c1"> <methods> <include name="m2"/> </methods> </class> </classes> </test> </suite> |
Administrator
|
xml does not look invalid. You could also open it in eclipse if it is not valid.
About your new attachment. I see the project as "p", I think it is not right. You need to browse your project first and then you should be able to browse suite (after selecting suite radio button).
~ seleniumtests.com
|
I just created a new package "p", it was like that.
I first selected the package (p), Then in the 2nd step, selected the radio button Suite. Then the Browse button disabled (did not return any popup). Error = Suite file not specified. Thanks for your time and effort. |
Administrator
|
By "package p" are you referring to "project p"?
As you specify the project and not package.
~ seleniumtests.com
|
This post was updated on .
Thank you so much Tarun, for your effort!
Just let me know - Do majority of (or some of us) testers run without testng.xml (or some config.xml). Direct runs. If so, I will stop this thread for now atleast. Whenever I am not able to run from xml, I change package and project and class etc. And I am sure, I select the correct project and package. I would like to say one thing - Instead of you put a lot of time verifying what went wrong in my steps, if u can just give the exact steps (1st, 2nd, 3rd etc.), I will check what I did wrong. Even after this I could not make it, then we can verify. Regards |
Administrator
|
I am attaching snap shot of one project and corresponding suite.
Lets see if this helps. If it does not then may be we could have skype call.
~ seleniumtests.com
|
I was able to run from testng.xml just now. However, please check my process:
Attaching screen shots. 1. I have 2 classes - c1.java and te.java. 2. I want to run these from xml. So, I selected the c1.Java and chose "Convert To TestNG" - 1.JPG 3. XML file was shown which has the pack1.c1 details. I included some methods into this xml, and saved.2.JPG It asked me to overwrite already existing testng.xml, I said OK.3.JPG 4. After this the newly created testng.xml was opened in Eclipse, and also shown in the Project Explorer. 4.JPG Maybe I can modify this xml (to include more classes te.java) to run all them. I need to try . |
Administrator
|
I am not aware of all the snapshots which you attached.
What I usually do is created testng.xml file manually and add classes or packages which are to be included in testing or not. A couple more examples are available here - http://testng.org/doc/documentation-main.html#testng-xml Good to hear that you are able execute tests now :)
~ seleniumtests.com
|
Thanks for your great help!
Yea, it took me 6-8 hours, though it was a small task. Just to create XML which controls everything. However, I am not satisfied with this - because the process should be different. Do u convert every java class into TestNG class? ex: you have 2 java classes; c1, c2. do u convert these 2 into testNG classes (using convert to testngclass) So the classes under the Run - Configuration - TestNG -> c1 and c2 as TestNG classes. |
Administrator
|
It's ok, don't give me so many thanks
If you want to help then share this forum in your circle of friends I don't convert class as TestNG class. I annotate each methods in class with @Test and then include fully qualifies name of class in testng.xml file. At time I just mention package in testng.xml file if writing each and every class becomes laborious
~ seleniumtests.com
|
Free forum by Nabble | Edit this page |