Submitted by harrydev on Thu, 01/14/2016 - 09:03
In previous tutorial we have seen executing testng.xml tests from command line. Now here we will look into executing testng.xml using batch file (.bat) file. A batch file (.bat) is used in DOS and Windows, which is an unformatted text file that consists of a series of commands to be executed by the command line interpreter.
Let us jump into simple example by taking two classes each has three or more @Test methods.
Submitted by harrydev on Mon, 01/11/2016 - 12:50
We can execute testng.xml file in different ways.
3. Ant / Maven
4. Command Line
5. Batch File.
Submitted by harrydev on Thu, 12/31/2015 - 03:22
When ever weexecute tests with TestNG, it will generate a default html report with basic information.
TestNG has provided an ability to implement 'IReporter' an interface which can be implemented to generate a customized report by users. It has 'generateReport()' method which will be invoked after all the suite has completed its execution and gives the report into the specified output directory.
Syntax for generateReport() method:
Submitted by harrydev on Sat, 04/18/2015 - 01:32
As we know, we can pass parameter values to the test methods during run time from testng xml file by specifying Parameters annotation to test method.
To do this, we need to declare parameters tag in xml file using 'name' and 'value' attribute.Where the name attribute of the tag defines name of the parameter and the value attribute defines the value of the parameter.
Submitted by harrydev on Wed, 04/01/2015 - 14:23
In this example we will see how to pass the data to Dataproviders by reading the data from excel sheet. DataProvider helps to send multiple sets of data to a test method. But here we need to make sure that the array returned by the dataprovider should match with the test method parameters.
We will write a simple program in which we will validate login screen by taking multiple usernames and passwords. The annotated method must return object where each object can be assigned to the test method one as username and the other parameter as password.
Submitted by harrydev on Mon, 01/26/2015 - 01:47
In this tutorial, we will see taking a screen shot with test name and placing it in a folder by creating a folder with Test Class Name.
As we are taking screen shots on failure, we need to add logic in creating a screen shot and naming it with test name and place it in its test class name respectively.
We can get the test class name using 'result.getInstanceName()'. Test class name looks some thing like "com.pack.sample.HomePage". But we need to create a folder name with test class name i.e 'HomePage'.
Submitted by harrydev on Mon, 12/29/2014 - 00:59
We have discussed about simple way of taking a screen shot earlier. Now in this tutorial, we will see how to take screen shot ONLY for failed tests.
Submitted by harrydev on Sun, 12/28/2014 - 09:28
We have seen an example to Re-run failed tests using iRetryListener. In the previous example, the count of the tests run was changing based on the maxRetryCountvalue. To over come that, we need to add the below code snippet for onFinish method by implementing 'ITestListener'
Submitted by harrydev on Sun, 12/28/2014 - 08:28
There may be many reasons for a Test case getting failed, may be due to element not found or time out exception or stale element exception etc. Normally in automation after executing scripts/tests, we will check for the results and if the test fails because of above reasons we will re-run then again.
Instead of that we can ask testNG to execute the failed test cases again for X (we can define) number of times and check for the updated results.
Submitted by harrydev on Fri, 12/05/2014 - 11:50
What is Assertion????
Asserts helps us to verify the conditions of the test and decide whether test has failed or passed. A test is considered successful ONLY if it is completed without throwing any exception.
Here we are verifying if the page title is equal to 'Google' or not. If the page title is not matching with the text / title that we provided, it will fail the test case.
To explain you what is assertion, lets us look into below code sample