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
1,739 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 7, 2019 by Vaishnavi
• 1,180 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
• 28,140 points
7,667 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 20, 2019 in Selenium by Abha
• 28,140 points
2,070 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,360 points
14,857 views
0 votes
2 answers

How to get the text from a website using selenium?

driver.findElement(By.cssSelector("p")).getText() or  IWebElement element = Browser.GetElementByCssSelector("div.loginbox p"); string text = ...READ MORE

answered Sep 6, 2020 in Selenium by Sri
• 3,190 points
25,695 views
0 votes
2 answers

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,500 points
13,686 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,149 views
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,910 points
7,228 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,880 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,180 points
654 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP