Skip to main content

Posts

Showing posts with the label ant

Print all the ant variables used!!!

Have a large build file and want to see what your ant variables contain? Use <echoproperties></echoproperties> in your target and you will get the list of ant properties with their values printed to standard output. You can redirect the output to a file using the attribute destfile as below <echoproperties destfile="allproperties">                    </echoproperties> You can always print individual values using echo as below <echo message=" testng.timeOut = ${ testng.timeOut }"/>

Working with User Defined Properties using ANT

Its quite useful to work with user defined properties using ANT. Lets say you have a build.xml in which you want to run a target based on a user input...In my case I want to decide on which URL to pass to Selenium based on the user selection of the stage to run the tests against... Add the following to the build.xml:  Now you can access the property from your program as  String urlString = System.getProperty("url"); If you are using TestNG framework, then you should add the property to your ant task in the build.xml file as:          To send this property from command line, you should send the property as  -Durl=

Failing to Run a single Testng Group

We all have various testng groups added/modified/deleted each time we update our test cases. Many a times we would want to run only a single testng group though! Failing tests? Pre Condition: My Test Automation Suite is based on Selenium-Ant-Testng When we want to run a single testng group lets say "sereUnitTests": If you don't have a beforemethod/beforetest/beforeclass annotation, then you should check your code...Its possible that something went wrong at the code level If you have a beforemethod/beforetest/beforeclass annotation, then you should check for the groups listed under each annotation For Ex: my beforemethod looks like this: @BeforeMethod(groups={"unit", "integration"}) public void openReader() throws SeleniumException { // Some functionality } But I see that the group which I wanted to run isn't listed thus testng notices that there is a before method to be initiated before your actual tests run but then doesn't ...