I'm using Junit under Ant to perform Selenium Test.My test cases need to read files which contain test data(in order to accomplish data driven test). I don't mind embedding the file names in the test cases, but I'd like to have the name of the directory where the data files are stored parameterized in the build.xml file.
What's the best way to pass information like that from build.xml down into the test cases? Is it a good idea to use ant property? Is it possible to inject Junit4 parameter from build.xml?
JUnit allows you to use parameters in a tests class. This class can contain multipletest methods and each method is executed with the different parameters provided. It helps developers save time when executing the same tests which differ only in their inputs and expected results.
Learn Maven and Ant the easy way! There are a number of JUnit extensions available. If you are unfamiliar with JUnit, you should download it from www.junit.org and read its manual. This chapter shows how to execute JUnit tests by using Ant. The use of Ant makes it straight forward through the JUnit task.
The junit task accepts nested sysproperty
elements.
<junit fork="no">
<sysproperty key="mydatadir" value="${whatever}"/>
...
</junit>
You can access these from within your tests using System.getProperty().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With