How to pass parameters to a Junit test case from the Ant build tool?

0 votes
I'm using JUnit under Ant to execute my Selenium test cases. My test cases need to read the files which contain some test data. I don't mind having the files names embedded in the test cases, but I'd like to have the name of the directory where the data files are stored in the build.xml file.

What's the best way to pass information like that from a build.xml file down into the test cases? Is it a good idea to use the ant property here? Is it possible to inject the Junit4 parameter from the build.xml file?
Mar 6 in Selenium by Surya
• 990 points
63 views

1 answer to this question.

0 votes

The JUnit task accepts nested system property elements.

<junit fork="no">
  <sysproperty key="mydatadir" value="${some piece of }"/>
  ...
</junit>

You can access these from within the tests using System.getProperty().

answered Mar 6 by Vaishnavi
• 1,120 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How to exclude a particular test group from a test case execution?

Hey Catherine, you can use exclude tag in the ...READ MORE

answered Jun 19 in Selenium by Abha
• 19,130 points
31 views
0 votes
1 answer

How to run Selenium test case file from command line?

You’ll need Selenium RC for this: http://seleniumhq.org/download/  And the ...READ MORE

answered Apr 23, 2018 in Selenium by Vardy
• 2,250 points
2,596 views
0 votes
1 answer

How to get the text from a website using selenium?

hey, you can use get.text() method to ...READ MORE

answered Dec 31, 2018 in Selenium by Sudhanshu
504 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
405 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
761 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
401 views
0 votes
1 answer
0 votes
1 answer

How to get the WebDriver version during test run?

Hi friend, It is possible by reading the VERSION.txt ...READ MORE

answered May 28 in Selenium by Vaishnavi
• 1,120 points
24 views