I need to read testng.xml file in java. When i run the java class the
testng.xml file should invoke and execute the test scripts.
Can any body help me in this. Its very urgent.
Thanks in advance.
Regards,
Raju.
I am not quite understanding your question here.Are you trying to have
your Java code start TestNG reading you testng.xml file, or do you
simply want to read the file in your code for some reason?
Simply reading the file will not cause your tests to automatically
start.
If you want to start TestNG from within your program, take a look at
this site:
http://testng.org/doc/documentation-main.html#running-testng-programmatically
I use that to start my tests so my program runs standalone and can be
invoked by a script/batch file. The calls it describes builds the XML
file in memory, although it does end up where you have it place the
reports eventually.
If you actually want to read the XML file try looking in the testng
code to see how it does it. There is probably some public methods it
is using that you can take advantage of yourself to do the same thing.
Mike
On Dec 15, 6:42 am, Raju <bgsraju....@gmail.com> wrote:
Regards,
Raju
On Dec 15, 11:15 am, Mike Riley <lvskip...@cox.net> wrote:
> Hi Raju,
>
> I am not quite understanding your question here.Are you trying to have
> yourJavacode start TestNGreadingyoutestng.xmlfile, or do you
> simply want to read thefilein your code for some reason?
>
> Simplyreadingthefilewill not cause your tests to automatically
> start.
>
> If you want to start TestNG from within your program, take a look at
> this site:http://testng.org/doc/documentation-main.html#running-testng-programm...
>
> I use that to start my tests so my program runs standalone and can be
> invoked by a script/batchfile. The calls it describes builds the XMLfilein memory, although it does end up where you have it place the
> reports eventually.
>
> If you actually want to read the XMLfiletry looking in the testng
> code to see how it does it. There is probably some public methods it
> is using that you can take advantage of yourself to do the same thing.
>
> Mike
>
> On Dec 15, 6:42 am, Raju <bgsraju....@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > I need to readtestng.xmlfileinjava. When i run thejavaclass the
> >testng.xmlfileshould invoke and execute the test scripts.
List<String> file = new ArrayList<String>();
file.add("Suite.xml");
TestNG testNG = new TestNG();
testNG.setTestSuites(file);
testNG.run();
Regards,
Raju
On Dec 16, 9:40 am, Gulshan Saini <gulshan.sa...@gmail.com> wrote:
> Please look at this tutorialhttp://www.selenium-testing.com/webdriver-page-objects-and-testng-tut...