Sunday, February 16, 2014

Log4j implementation

Following are the steps to generate logs for the applications,

Step1: Create one sample project
Step2: Create Package in the project to place java classes
Step3: Download Lo4j jar file from http://logging.apache.org/log4j/1.2/download.html
Step4: Add log4j jar file to the project build path
Step5: Create log4j property file at the project level and add the properties into the file as shown in fig1.

#All==>all messages
#WARN==>only warning message  etc..
log4j.rootLogger=ALL

#log4j.logger.<Package>=,<log file name>FileAppender
log4j.logger.com.pack=,logTestFileAppender

# junit_log4jFileAppender - used to log messages in the junit_log4j.log file.
log4j.appender.logTestFileAppender=org.apache.log4j.FileAppender
log4j.appender.logTestFileAppender.File=logTest.log
log4j.appender.logTestFileAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.logTestFileAppender.layout.ConversionPattern=%d{dd MMM yyyy HH:mm:ss} %-4r [%t] %-5p %c %x - %m%n
 Fig 1: log.properties

Step6: Create one java class in the package
Step7: Create reference variable for logger class as shown in fig2.

public static Logger logger=Logger.getLogger(classname.class)
                Fig2: Reference Variable for Logger Class

Step8: In the main method load the logger properties by using configure() method in PropertyConfigurator Class.
Step9: By using Logger reference variable write info, debug and error etc types of logs as shown in fig3.

Logger.info(“START:: Starting of some XY()”);
Logger. debug(“Values passed to the some XY() are ::  a: ”+a);
 Logger. error(“ERROR:: Error occurred in some XY()”);
                Fig3: Sample code to write info, debug and error logs

Step10:  After completion of code run the project and find the generated logs in the path given in log.propeties for the property log4j.appender.logTestFileAppender.File”.

Example:

package com.pack;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class LogExample {

    public static Logger logger=Logger.getLogger(LogExample.class);
   
    public void test() {
        WebDriver driver=new FirefoxDriver();
        logger.info("Browser Launched");
        driver.get("http://www.gmail.com");
        logger.info("URL Entered");
        logger.debug("Hi");
        logger.fatal("Hello");
    }
    public static void main(String[] args) {
        PropertyConfigurator.configure("log.properties");
LogExample example=new LogExample();
example.test();
    }

}
 

Wednesday, January 8, 2014

Differences between Quality Assurance and Quality control


Sno
Quality Assurance
Quality Control
1
Quality assurance is a planned and systematic set of activities necessary to provide adequate confidence that products and services will conform to specified requirements and meet user needs.
Quality control is the process by which product quality is compared with applicable standards,
and the action taken when nonconformance is detected.
2
Quality assurance is a staff function, responsible for implementing the quality policy defined through the development and continuous improvement of software development processes.
Quality control is a line function, and
the work is done within a process to ensure that the work product conforms to standards and
requirements.
3
Quality assurance is an activity that establishes and evaluates the processes that produce
products.
Quality control activities focus on identifying defects in the actual products produced. These
activities begin at the start of the software development process with reviews of requirements,
and continue until all application testing is complete.
4
Quality assurance helps establish processes.
Quality control relates to a specific product or service.
5
Quality assurance sets up measurement programs to evaluate processes.
Quality control verifies whether specific attribute(s) are in, or are not in, a specific product or service.
6
Quality assurance identifies weaknesses in processes and improves them.
Quality control identifies defects for the primary purpose of correcting defects.
7
Quality assurance is a management responsibility
Quality control is the responsibility of the team/worker.
8
Quality assurance is concerned with all of the products that will ever be produced by a process.
Quality control is concerned with a specific product.
 
Compiled from CSTE CBOK

Thursday, January 2, 2014

2013: Major software failures

2013: Major software failures

Every industry is impacted with software  failures/bugs in 2013. It is very important to perform extensive QA &  testing before release to market to avoid losses

1) Health Care: 
Sebelius admitted that the testing done before the Oct. 1 launch was "clearly not" enough. "We did not adequately do end-to-end testing," she said.

http://www.foxnews.com/politics/2013/10/30/sebelius-to-face-grilling-at-hearing-on-glitch-ridden-obamacare-website-rollout/

2) Airlines:
"Sabre is experiencing a system issue,"

http://www.cnn.com/2013/08/06/travel/sabre-outage-flight-delays/

3) Financial:

A mysterious technical glitch halted trading on the Nasdaq

http://news.yahoo.com/nasdaq-trading-halts-3-hours-due-glitch-203619288.html

4) Retail:

"We experienced a technical error that caused some items to show incorrect pricing," Walmart

http://abcnews.go.com/Business/walmart-super-low-prices-website-glitch/story?id=20804317

5) Payroll:

California sues SAP over payroll system failures

http://articles.latimes.com/2013/nov/21/local/la-me-pc-california-sues-sap-20131121

Compiled by Damodhara Reddy Jammli( DJ)

Monday, December 23, 2013

Automation object model in QTP (AOM)

Automation object model is nothing but structural representation of objects,methods and properties which are used to perform quicktest operations.Automation enables software packages to expose their unique features to scripting tools and other applications. You can use the QuickTest Professional Automation Object Model to write programs that automate your QuickTest operations.

QuickTest Professional is COM Server and its different methods and properties are exposed by its COM interface which can be accessed by other applications and scripting tools to control it from outside.

To create the automation object, we use “CreateObject” function. Once the object has been created, we can access all other objects, methods and properties of the QuickTest . CreateObject creates and returns the reference to an automation object.


You can write a script that modifies the test object description properties in the Object Identification dialog box and performs an update run on all tests in a specified file folder.

You can define your settings for a test in QuickTest, then click “Generate Script” in the Generate tab of the Test Settings dialog box to generate an automation script based on the current test settings. You can then apply those same settings automatically to multiple tests using the whole automation script or excerpts from the generated file.

Generating an automation script for QuickTest Professional options:

• Navigate to Tools > Options > General and click on the “Generate Scripts” buttons
• Navigate to File > Settings>Properties and click on the “Generate Scripts” buttons
• Navigate to Tools > Object Identification and click on the “Generate Scripts” buttons

Example:
Launch QTP, open an existing test and Run the Test and Store Run Results in Specified Folder:

Dim qtApp
Dim qtTest
Dim qtResultsOpt

'Create the QTP Application object
Set qtApp = CreateObject("QuickTest.Application")

'If QTP is notopen then open it
If  qtApp.launched <> True then

qtApp.Launch

End If

'Make the QuickTest application visible
qtApp.Visible = True

'Set QuickTest run options
qtApp.Options.Run.ImageCaptureForTestResults = "OnError"
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ViewResults = False

'Open the test in read-only mode
qtApp.Open "C:\Program Files\HP\QuickTest Professional\Tests\AOMExamp;e", True

'set run settings for the test
Set qtTest = qtApp.Test

'Instruct QuickTest to perform next step when error occurs
qtTest.Settings.Run.OnError = "NextStep"

'Create the Run Results Options object
Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

'Set the results location
qtResultsOpt.ResultsLocation = "D:\AOMTestResult"

' Run the test
qtTest.Run qtResultsOpt

'Check the results of the test run
MsgBox qtTest.LastRunResults.Status

'Close the test
qtTest.Close

'Close QTP
qtApp.quit

'Release Object
Set qtResultsOpt = nothing
Set qtTest = Nothing
Set qtApp = Nothing

Tuesday, September 17, 2013

HTML reports in QTP

To get html reports after every execution follow the below steps which is one time configuration

1. Open registry
Start > Run > Regedit and click enter

2. Registry will be opened

3. Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Mercury Interactive\QuickTest Professional\Logger\Media\Log

4. Change the active DWORD from 0 to 1.

5. Open QTP and run a test. After the execution, the HTML report will be generated and stored in the results folder with name "log"

Associating function library in QTP

Function library can be associated in design time or run-time depending on the framework used.

To associate the function library at design time

navigate to ‘File > Settings > Resources > Associate Function Library’ option in QTP. Click on '+' button and browse for the file and add it to the Test

To associate the function library at run time, you can use any of the following

1) Automation Object Model (AOM)

'Open QTP
Set objQTP = CreateObject("QuickTest.Application")
objQTP.Launch
objQTP.Visible = True

'Open a test
objQTP.Open "D:\Automation\Test1", False, False
Set objFL = objQTP.Test.Settings.Resources.Libraries

'check if it is already associated, else associate it
If objFL.Find("D:\Automation\FunctionLibrary.vbs") = -1 Then
  objFL.Add "D:\Automation\FunctionLibrary.vbs", 1
End


2) using ExecuteFile method.

ExecuteFile "D:\Automation\FunctionLibrary.vbs"

3) using LoadFunctionLibrary method.

LoadFunctionLibrary "D:\Automation\FunctionLibrary.vbs"

Action template in QTP

Action Template is a feature in QTP that allows you to include predefined template for every new actions by default. The template will be included automatically every time you create a new action.

This is a good practice to track few things like purpose, create by, revision history etc.

Example: If the below template is to be set as an action template,


'=========================================================================
'Action Name -
'Purpose -
'Created by -
'Date -

'Change History
'- - - - - - - - - - - - - -
'Date Changed by Comments
'
'=========================================================================

1. Open notepad and copy the above code to it.

2. Save the notepad as "ActionTemplate.mst"

NOTE: Use the double quote while saving the file as this wouldnt add .txt for the file extension.

3. Go to <dat> folder inside QTP installation folder.

Normally it can be found under C:Program Files\Mercury Interactive\QuickTest Professional\dat for versions of QTP below 11 and under C:Program Files\HP\Unified Functional Testing\dat for UFT 11.0 or above.

4. Add the ActionTemplate.mst file in the dat folder.

5. Open QTP and insert a new action. The new action should display the statements that you had saved in the Action Template.

Action Template in QTP




AI in Software Testing: How Artificial Intelligence Is Transforming QA

For years, software testing has lived under pressure: more features, faster releases, fewer bugs, smaller teams. Traditional QA has done her...