Building test using Ant and TestNg, how to accept user input ?

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

Building test using Ant and TestNg, how to accept user input ?

Pooja
Dear C`edric,

Thanks a ton for developing such an amazing tool.

Well, I want to know, do we have any tag when running testNg test from Ant, to accept user input and then proceed again?
1. I have a test class with test scannerTest

@Test
public void scannerTest()
{
    int a,b;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter 1st no.:");                //line 1
    a=sc.nextInt();                                        
    System.out.println("Enter 2nd no.:");             //line 2
    b=sc.nextInt();                           
    System.out.println("Total is:"+(a+b));
}

2. in ANT, I'm writing

<target name="run" depends="compile">
        <testng outputdir="${output}" classpathref="project.classpath" haltonfailure="yes" >
              <xmlfileset dir="${src}/." includes="testNg.xml"/>
        </testng>
 </target>
3. Now if I run it, it doesn't wait for user input and just fail after line no 1.

compile:
run:
   [testng] [Parser] Running:
   [testng]   D:\Workspace\TestTestNG\src\TestNg.xml
   [testng] Enter 1st no.:
   [testng] ===============================================
   [testng] Test
   [testng] Total tests run: 1, Failures: 1, Skips: 0
   [testng] ===============================================

But if same I do it running tesNg.xml directly, it works fine.  So please share if there is any work around to make it work using ant build as well?

Note: I tried using passing parameters also but that too didn't work.

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Building test using Ant and TestNg, how to accept user input ?

⇜Krishnan Mahadevan⇝
Pooja,
Why not consider passing input via JVM args instead of pausing and waiting for the user to input data ?

On Thursday, May 16, 2013, pooja wrote:
Dear C`edric,

Thanks a ton for developing such an amazing tool.

Well, I want to know, do we have any tag when running testNg test from Ant, to accept user input and then proceed again?
1. I have a test class with test scannerTest

@Test
public void scannerTest()
{
    int a,b;
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter 1st no.:");                //line 1
    a=sc.nextInt();                                        
    System.out.println("Enter 2nd no.:");             //line 2
    b=sc.nextInt();                           
    System.out.println("Total is:"+(a+b));
}

2. in ANT, I'm writing

<target name="run" depends="compile">
        <testng outputdir="${output}" classpathref="project.classpath" haltonfailure="yes" >
              <xmlfileset dir="${src}/." includes="testNg.xml"/>
        </testng>
 </target>
3. Now if I run it, it doesn't wait for user input and just fail after line no 1.

compile:
run:
   [testng] [Parser] Running:
   [testng]   D:\Workspace\TestTestNG\src\TestNg.xml
   [testng] Enter 1st no.:
   [testng] ===============================================
   [testng] Test
   [testng] Total tests run: 1, Failures: 1, Skips: 0
   [testng] ===============================================

But if same I do it running tesNg.xml directly, it works fine.  So please share if there is any work around to make it work using ant build as well?

Note: I tried using passing parameters also but that too didn't work.

--
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?hl=en.
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.