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, 2019 in Selenium by Surya
• 970 points
240 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, 2019 by Vaishnavi
• 1,170 points

Related Questions In Selenium

0 votes
1 answer

How to pass parameter through testng.xml file to a test case in Selenium Webdriver?

Hello Revathi, to pass parameter through testng.xml ...READ MORE

answered Jun 12, 2019 in Selenium by Abha
• 27,720 points
868 views
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, 2019 in Selenium by Abha
• 27,720 points
149 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,350 points
3,806 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
3,099 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,510 points
1,467 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,850 points
1,451 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,850 points
1,214 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, 2019 in Selenium by Vaishnavi
• 1,170 points
39 views