Re: [testng-users] Building test using Ant and TestNg, how to accept user input ?

35 views
Skip to first unread message

Krishnan Mahadevan

unread,
May 16, 2013, 12:58:54 PM5/16/13
to testng...@googlegroups.com
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 testng-users...@googlegroups.com.
To post to this group, send email to testng...@googlegroups.com.
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/
Reply all
Reply to author
Forward
0 new messages