Posts

Showing posts from April, 2019

Listeners

Image
What are Listeners in TestNG  : - To say it in simple words, we can make TestNG to listen what we say with the help of Listeners. Listeners give us the flexibility to modify default TestNG's behaviors. By using TestNG listeners 'ITestListener' or 'TestListenerAdapter' we can change the default behaviour write our own implementation when a Test fails or Skips etc. We have extended TestListenerAdapter which intern implements ITestListener with empty methods. So again we don't have to override other methods from the ITestListener interface which we may not needed. We will see the below list of methods in the example OnTestStart  : Invoked each time before a test will be invoked. OnTestSuccess  : Invoked each time a test succeeds. OnTestFailure  : Invoked each time a test fails We can implement any logic that you want to do when a test fails OnTestSkipped  : Invoked each time a test is skipped. OnTestFinish  : Invoked after all the tests ha...

TestNG-Setup

> Install TestNG In Eclipse IDE Via Offline Jar Files Download the latest TestNG Jar files from the link  TestNg Jars Go to the eclipse installation directory and look for the “ dropins ” folder there. Create a folder inside the  dropins  folder and name it as “testng-eclipse-6.11“ Extract the “site_assembly.zip” file and copy its contents to the newly created “testng-eclipse-6.11” directory. Restart Eclipse Resource:  https://stackoverflow.com/questions/10720263/unable-to-read-repository-at-http-beust-com-eclipse

Log4J

Image
1.Get the jar file and configure in project. 2.Create a Log4j.properties file in project. #Application Logs log4j.logger.devpinoyLogger=DEBUG, dest1 log4j.appender.dest1=org.apache.log4j.RollingFileAppender log4j.appender.dest1.maxFileSize=5000KB log4j.appender.dest1.maxBackupIndex=3 log4j.appender.dest1.layout=org.apache.log4j.PatternLayout log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n log4j.appender.dest1.File=F:\\AfterMarriage\\Log4j\\Application.log #do not append the old file. Create a new log file everytime log4j.appender.dest1.Append=false 3.Call the Logger class import org.apache.log4j.Logger; public class TestLog { public static void main (String[]args){ Logger Application_Logs = Logger.getLogger("devpinoyLogger"); Application_Logs.debug("Starting the Programme"); Application_Logs.debug("Running the Programme"); Application_Logs.debug("Processing the Programme"); ...