Configuration fails on trying to execute testng from code

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

Configuration fails on trying to execute testng from code

Abhishek Bisht
Hi All,

I am trying to run testng.xml from inside a servlet but on executing it I am getting configuration exception and all test are skipped.

My servlet class

if ("firefox".equals(action)) {
try{
System.out.println("inside firefox");
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<String>();
suitefiles.add("filepath\\testng.xml");
runner.setTestSuites(suitefiles);
runner.run();
}

On runner.run() error is thrown.

My project is working fine if I run it from eclipse as testng project

Thanks in advance

Regards
Abhishek

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Configuration fails on trying to execute testng from code

Krishnan Mahadevan
Abhishek,

How are you running your servlet ? I am guessing that you must be packing it as a war and then deploying it on a tomcat to get your servlet up and running.

I am also guessing that your tests that are part of your testng.xml are under src/test/java.
I don't think that your war file gets bundled with test classes. AFAIK when you build a war/jar only the classes under src/main/java get bundled.

So that perhaps is why your execution conks when you try to trigger it via the servlet invocation, but works fine when you run it from eclipse.

All said and done, you would need to add a bit more context to your query for anyone to help you out. The fact that TestNG test classes are executed from eclipse itself re-iterates that there's nothing wrong with your test classes or with TestNG for that matter.




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/
My Technical Scribbings @ http://rationaleemotions.wordpress.com/

On Tue, Apr 26, 2016 at 3:22 PM, Abhishek Bisht <[hidden email]> wrote:
Hi All,

I am trying to run testng.xml from inside a servlet but on executing it I am getting configuration exception and all test are skipped.

My servlet class

if ("firefox".equals(action)) {
try{
System.out.println("inside firefox");
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<String>();
suitefiles.add("filepath\\testng.xml");
runner.setTestSuites(suitefiles);
runner.run();
}

On runner.run() error is thrown.

My project is working fine if I run it from eclipse as testng project

Thanks in advance

Regards
Abhishek

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Configuration fails on trying to execute testng from code

Abhishek Bisht
Thanks Krishnan for replying, yes I was executing the same way as you mentioned and really sorry for not providing detail information , now its working fine as the error was @beforesuite and there was some configuration problem after rectifying which now its working fine.
Thanks again for reply.

On Thursday, 28 April 2016 09:48:27 UTC+5:30, Krishnan wrote:
Abhishek,

How are you running your servlet ? I am guessing that you must be packing it as a war and then deploying it on a tomcat to get your servlet up and running.

I am also guessing that your tests that are part of your testng.xml are under src/test/java.
I don't think that your war file gets bundled with test classes. AFAIK when you build a war/jar only the classes under src/main/java get bundled.

So that perhaps is why your execution conks when you try to trigger it via the servlet invocation, but works fine when you run it from eclipse.

All said and done, you would need to add a bit more context to your query for anyone to help you out. The fact that TestNG test classes are executed from eclipse itself re-iterates that there's nothing wrong with your test classes or with TestNG for that matter.




Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ <a href="http://wakened-cognition.blogspot.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwakened-cognition.blogspot.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHzOdYJCASIDF_28vQtkp9gnKAYSQ&#39;;return true;">http://wakened-cognition.blogspot.com/
My Technical Scribbings @ <a href="http://rationaleemotions.wordpress.com/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Frationaleemotions.wordpress.com%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEcBOKyRn0lpL8LDbBuyAlKdwgXwQ&#39;;return true;">http://rationaleemotions.wordpress.com/

On Tue, Apr 26, 2016 at 3:22 PM, Abhishek Bisht <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="Ug-kw-SbAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">abhishek....@...> wrote:
Hi All,

I am trying to run testng.xml from inside a servlet but on executing it I am getting configuration exception and all test are skipped.

My servlet class

if ("firefox".equals(action)) {
try{
System.out.println("inside firefox");
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<String>();
suitefiles.add("filepath\\testng.xml");
runner.setTestSuites(suitefiles);
runner.run();
}

On runner.run() error is thrown.

My project is working fine if I run it from eclipse as testng project

Thanks in advance

Regards
Abhishek

--
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:" target="_blank" gdf-obfuscated-mailto="Ug-kw-SbAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng-users...@googlegroups.com.
To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="Ug-kw-SbAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">testng...@....
Visit this group at <a href="https://groups.google.com/group/testng-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/testng-users&#39;;return true;">https://groups.google.com/group/testng-users.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Configuration fails on trying to execute testng from code

bala krishna
In reply to this post by Abhishek Bisht
Hi Abhishek ,,

I hope you issued is fixed,I am also trying same ,but facing issue ,can you please send u r sample code to email  : [hidden email], I wil follow that and fix my issue.

Thanks...

On Tuesday, April 26, 2016 at 3:22:32 PM UTC+5:30, Abhishek Bisht wrote:
Hi All,

I am trying to run testng.xml from inside a servlet but on executing it I am getting configuration exception and all test are skipped.

My servlet class

if ("firefox".equals(action)) {
try{
System.out.println("inside firefox");
TestNG runner = new TestNG();
List<String> suitefiles = new ArrayList<String>();
suitefiles.add("filepath\\testng.xml");
runner.setTestSuites(suitefiles);
runner.run();
}

On runner.run() error is thrown.

My project is working fine if I run it from eclipse as testng project

Thanks in advance

Regards
Abhishek

--
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 https://groups.google.com/group/testng-users.
For more options, visit https://groups.google.com/d/optout.