Posts

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"); ...

Java DataBase Connectivity JDBC

java database connectivity jdbc Test data from database/validate database Mysql.-Installation: Database connectivity with java:- **driver(jars) to connect different DB ---Install the MYSQL-->start the services of Mysql---> cmd -->path of mysql BIN -->mysql -u root(to connect using user id 'root') create a database: create database sudheer; show databases; create table; inserted data into table; ----------------------------------------------- add mysql jar to ecllipse: Java code: Connetion (interface)->it helps to connect to the DB     Connection conn = null;                 String url="jdbc:mysql://localhost:3306/";(path of mysql)         String driver="com.mysql.jdbc.driver";         String dbName="sudheer";[connecting to DB]         String Username="root";         String passwor...

Maven build creation

Image
1-Download the maven and unzip 2- Maven life cycle: 1-MAVEN COMPILE - java classes,code  will be compile (maven compiler plugin )-TO COMPILE  2-MAVEN TEST - test cases, unit,regression,functional(maven surefile plugin)-TO TEST  3-MAVEN RESOURCE --jar-- >JAR's/WAR's/EAR's--Resources(maven Resource plugin)- TO CREATE RESOURCE JAR'S AND WAR'S web application we create war files(will give to QA team and they will test it) Maven dependecy - pom.xml Commands: 1)mvn clean install ---> it will execute all complete life cycle maven compile , maven test and maven resource 2)MVN test :----> execute only test cases 3) MVN package -DskipTests : --->  SKIP the test cases and create Only build. OR 4)mvn package -Dmaven.test.skip=true Steps for selenium maven build creation <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xs...