issue with running testng programatically....

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

issue with running testng programatically....

joshuaperumalla
Hi All,
          I want to call my testng.xml file with java program.... But the issue is I have many .xml files so Now I need to give the name of the .xml file as well... but Im unable to give the name of the testng.xml file...
Any Ideas , please help me out.

public static void info() {
       
        TestNG testng = new TestNG();
        ------ here i have to give my testng.xml name as well---------------------------
        testng.setXmlSuites(getSuite());
        testng.run();

    }
  
    public static List<XmlSuite> getSuite() {
        List<XmlSuite> suites = new ArrayList<XmlSuite>();
        XmlSuite eachSuite = new XmlSuite();
        eachSuite.setName("CriticalSmoke Suite");
        eachSuite.setTests(getTest(eachSuite));
        System.out.println(eachSuite.toXml());
        suites.add(eachSuite);
        return suites;
    }

    public static List<XmlTest> getTest(XmlSuite suite) {
        List<XmlTest> tests = new ArrayList<XmlTest>();
        XmlTest eachTest = new XmlTest();
        tests.add(eachTest);
        eachTest.setName("critical");
        eachTest.setSuite(suite);
        return tests;
    }
Regards,
Thanks Joshua

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: issue with running testng programatically....

Krishnan Mahadevan
Why are you unable to do so ?
You could pass the file name as a arg to the main method [ program argument ] or you could pass them via VM arguments or you could make your program look for .xml files in the current dir or a specific did and work with it. There are so many approaches. Why doesn't any of them not work for you ??

On Thursday, September 5, 2013, joshua p wrote:
Hi All,
          I want to call my testng.xml file with java program.... But the issue is I have many .xml files so Now I need to give the name of the .xml file as well... but Im unable to give the name of the testng.xml file...
Any Ideas , please help me out.

public static void info() {
       
        TestNG testng = new TestNG();
        ------ here i have to give my testng.xml name as well---------------------------
        testng.setXmlSuites(getSuite());
        testng.run();

    }
  
    public static List<XmlSuite> getSuite() {
        List<XmlSuite> suites = new ArrayList<XmlSuite>();
        XmlSuite eachSuite = new XmlSuite();
        eachSuite.setName("CriticalSmoke Suite");
        eachSuite.setTests(getTest(eachSuite));
        System.out.println(eachSuite.toXml());
        suites.add(eachSuite);
        return suites;
    }

    public static List<XmlTest> getTest(XmlSuite suite) {
        List<XmlTest> tests = new ArrayList<XmlTest>();
        XmlTest eachTest = new XmlTest();
        tests.add(eachTest);
        eachTest.setName("critical");
        eachTest.setSuite(suite);
        return tests;
    }
Regards,
Thanks Joshua

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users%2Bunsubscribe@googlegroups.com&#39;);" target="_blank">testng-users+unsubscribe@....
To post to this group, send email to <a href="javascript:_e({}, &#39;cvml&#39;, &#39;testng-users@googlegroups.com&#39;);" target="_blank">testng-users@....
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: issue with running testng programatically....

joshuaperumalla
Hi Krishnan,
                   I am done with writing the code for creating testNg programatically... but now the issue is when i pass multiple <test> names it is creating multiple xml files but now what i need is when i pass multiple <test> names it should create only one xml file with those many <test> tags in it....

public static XmlSuite getSuite(String program, String group) {
XmlSuite eachSuite = new XmlSuite();
eachSuite.setName("aaaaa");
eachSuite.setParallel("tests");
eachSuite.setVerbose(5);
eachSuite.setTests(getTest(eachSuite, program, group));
System.out.println(eachSuite.toXml());
return eachSuite;
}
public static List<XmlTest> getTest(XmlSuite suite, String program,
String group) {
List<XmlTest> tests = new ArrayList<XmlTest>();
XmlTest eachTest = new XmlTest();
eachTest.setName("");
               eachTest.setXmlClasses(classes);
eachTest.setSuite(suite);
tests.add(eachTest);
return tests;
}
this is creating multiple suits when i call it with multiple test names ... but i need it create only one suite with following test tags for the names which i pass

On Friday, September 6, 2013 8:32:55 AM UTC+5:30, Krishnan wrote:
Why are you unable to do so ?
You could pass the file name as a arg to the main method [ program argument ] or you could pass them via VM arguments or you could make your program look for .xml files in the current dir or a specific did and work with it. There are so many approaches. Why doesn't any of them not work for you ??

On Thursday, September 5, 2013, joshua p wrote:
Hi All,
          I want to call my testng.xml file with java program.... But the issue is I have many .xml files so Now I need to give the name of the .xml file as well... but Im unable to give the name of the testng.xml file...
Any Ideas , please help me out.

public static void info() {
       
        TestNG testng = new TestNG();
        ------ here i have to give my testng.xml name as well---------------------------
        testng.setXmlSuites(getSuite());
        testng.run();

    }
  
    public static List<XmlSuite> getSuite() {
        List<XmlSuite> suites = new ArrayList<XmlSuite>();
        XmlSuite eachSuite = new XmlSuite();
        eachSuite.setName("CriticalSmoke Suite");
        eachSuite.setTests(getTest(eachSuite));
        System.out.println(eachSuite.toXml());
        suites.add(eachSuite);
        return suites;
    }

    public static List<XmlTest> getTest(XmlSuite suite) {
        List<XmlTest> tests = new ArrayList<XmlTest>();
        XmlTest eachTest = new XmlTest();
        tests.add(eachTest);
        eachTest.setName("critical");
        eachTest.setSuite(suite);
        return tests;
    }
Regards,
Thanks Joshua

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users+unsubscribe@googlegroups.com.
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.


--
Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/groups/opt_out.