Showing posts from March, 2012

Fitnesse from Command line

In continuation to my previous post "Integrating QC with Fitnesse"
Here are the commandline options for running Fitnesse:

All tests run in a single process unlike the web server test executions.It's easily debuggable. It removes the need to start a local FitNesse server to run tests.Can generate HTML output to a fileCan generate XML output to a file Sample Command:
java -jar fitnesse.jar -p "&strPort&" -c "&strFITTestScriptName&" > "&strExpectedResultsPath

Command line options:
This option will print FitNesse protocol actions to the console.-v
This option should give a verbose output about test progress to the console-results file
The result of the testrun is saved to a textfile with the given name.-html file
The result of the testrun is saved to a html file with the given name.-xml file
The result of the testrun is saved to a xml file with the given name. -nopath
This option will make FitNesse ignore !path opt…

VBA - Combine worksheets in Excel and Kill all excel objects

This is a simple vba script that will let you combine excel work sheets and make sure no orphan excel objects are pending.

Sub CopyFromWorksheets()
Dim wrk As Workbook
Dim sht As Worksheet
Dim trg As Worksheet
Dim rng As Range
Dim colCount As Long
'Dim sheetDelimiter As String
' Creates excel app object
Set objExcel = CreateObject("Excel.Application")

' Makes the excel invisible
objExcel.Visible = False
' Supress all display alerts
objExcel.DisplayAlerts = False
' Gets the complete path of the active excel sheet
strExcelFilePath = ActiveWorkbook.FullName

' Opens the excel file
Set objWorkbook = objExcel.Workbooks.Open(Trim(strExcelFilePath))

Set objWorkSheet = objWorkbook.Worksheets("Merge")
' Gets the count of column
Set objRange = objWorkbook.Worksheets("Merge")
numRowsCount = objRange.Evaluate("COUNTA(A1:A100)")
'sheetDelimiter = "######"
Set wrk = …

QC OTA - Test Lab

Here are some amazing functions that can be reused wrt QC OTA for Test Lab module: - Create Test Set - Add tests to Test Set - Create the supplied directory structure in the test lab - Create a test set underneath a given parent - Return a test set if it exists - Returns a testsetfolder for the given path Public Function TestLabCreateTestSet(strFolderPath As String, strTestSetName As String, ByRef CreatedTestSet As TestSet)     Dim tstSetFolder As TestSetFolder
    Dim testSetFolderF As TestSetTreeManager
    Dim TestSetF As TestSetFactory
    Dim testSet1 As TestSet
    Dim oTestSet As TestSet

    'Does the test set already exist? If so return it
    Set oTestSet = TestLabGetTestSet(strFolderPath, strTestSetName)
    If Not (oTestSet Is Nothing) Then
        'MsgBox "Test Set Already Exists: " & strFolderPath & "\" & strTestSetName
        Set CreatedTestSet = oTestSet
        Exit Function
    End If

    Set testSetFolderF = tdc.TestSetTreeMana…

QC OTA - Test Plan - 2

- Find Test in Test Plan
- Return a SubjectNode object for a given path in the Test Plan

Function TestPlanFindTest(ByVal strTestName As String, ByVal strFolderToSearchPath As String, ByVal SearchChildFolders As Boolean, Optional ByVal strTestType As String, Optional blnSilentMode As Boolean) As Test

    Dim oParentNode As SubjectNode
    Dim SubjectNodeList As List
    Dim oSubjectNode As SubjectNode
    Dim intMatchCount As Integer: intMatchCount = 0
    Dim TestFact As TestFactory
    Dim oReturnValue As Test
    Dim TestFilter As TDFilter
    Dim TestList As List
    Dim oTest As Test
    Dim blnTypedMatched As Boolean: blnTypedMatched = True

    Set oParentNode = TestPlanGetSubjectNode(strFolderToSearchPath)
    Set TestFact = tdc.TestFactory

    'If there was an error getting the parent node then exit
    If (oParentNode Is Nothing) Then
        Set TestPlanFindTest = Nothing
        Exit Function
    End If
    'See if the parent folder has any tests that match the name we…

QC OTA - Test Plan - 1

Here are some amazing functions that can be reused wrt QC OTA for Test Plan module: - Copy paste within Test Plan
- Create folder structure within Test Plan
- Does a particular path exist in Test Plan
- Does a [particular test exist in Test Plan

Function TestPlanCopyPasteTest(strSourceFolderPath, strDestFolderPath, strSourceTestName, strNewTestName) As Boolean
'Copy a test, including design steps and parameters.
' For example:
' CopyPasteTest "Subject\TestFolder1", "Subject\TestFolder2", "Test1"
' Copies Test1 to TestFolder2

Dim sourceFolder As SubjectNode
Dim destFolder As SubjectNode
Dim treeMng As TreeManager
Dim iscp As ISupportCopyPaste
Dim clipboard As String
Dim oSourceTest As Test
Dim oNewTest As Test

'Check that the source file exists
If Not TestPlanDoesTestExist(strSourceTestName, strSourceFolderPath, False, "") Then
TestPlanCopyPasteTest = False
MsgBox "Source test does not exist: " & strSourceFolderPat…

Read Registry on remote machines VbScript

Here is a simple code to read any part of the registry from any machine , provided you have admin rights on the target machine: Const HKEY_LOCAL_MACHINE = &H80000002Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & "Machine Name" & "\root\default:StdRegProv")strKeyPath = "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"strValueName = "BU"oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValuemsgbox strValueModify the strKeyPath and the strValueName and you can read any value in the registry!

Agile Adoption wrt Automation

The practice of Refactoring code changes the structure (i.e., the design) of the code while maintaining its behaviorCosts are reduced because continuous refactoring keeps the design from degrading over time, ensuring that the code is easy to understand, maintain, and change.Automated Acceptance Tests
Automated acceptance tests are tests written at the beginning of the iteration that answer the question: “what will this requirement look like when it is done?”. This means that you start with failing tests at the beginning of each iteration and a requirement is only done when that test passes.This practice builds a regression suite of tests in an incremental manner and catches errors, miscommunications, and ambiguities very early on. This, in turn, reduces the amount of work that is thrown away and therefore enables building less. The tests also catch bugs and act as a safety-net during change.Best Practices
More up front position of the test teamRealistic time for test designMore visibili…

AutoIt Scripting Language and SDK - Part Three

Understanding – Scripting Style – X control

The ActiveX control or dll’s can provide a extended support to the other scripting languages with the features AutoIt provides. An example Notepad automation VBScript is shown here. – Example WSH Script (VBScript) Require Variants to be declared before used Option Explicit ' Declare Variables & Objects Dim oShell Dim oAutoIt ' Initialise Variables & Objects Set oShell = WScript.CreateObject("WScript.Shell“) Set oAutoIt = WScript.CreateObject("AutoItX3.Control") ' Start of Script WScript.Echo "This script will run notepad and type in some text" oShell.Run "notepad.exe", 1, FALSE ' Wait for the Notepad window to become active oAutoIt.WinWaitActive "Untitled - Notepad", "" ' Send some keystokes to notepad oAutoIt.Send "Hello, this is line 1{ENTER}“ oAutoIt.Send "This is line 2{ENTER}This is line 3“ oAutoIt.Sleep 1000 oAutoIt.Send "!{F4}“ oAutoIt.WinWaitActive "N…

AutoIt Scripting Language and SDK - Part Two

Understanding – SciTE Editor
 SciTE is a cross-platform text editor. Lightweight and built for speed, it is designed mainly for source editing, and performs syntax highlighting and inline function reference for many different languages. The editor comes with the package with the AutoIt command auto complete feature. Which makes scripting easy.It can compile, build and run the scripts.Understanding – Scripting Style
C like import facility. –#include "[path\]filename“, #include , #include-onceVariables starts with ‘$’ sign –$Mid="M1009944“Commenting – ‘;’;This is a commentLooping Regular ExpressionsUnderstanding – Scripting Style -GUI
 Any GUI script will need to #include for basic GUI related constants. For advanced controls we need to add additional files.Lets create a window :-We can call it “Hello World”. It will be a window of 200 by 100 pixels in size.Remember : When a new window is created it is hidden - so we must "show" it.Code : -#include GUICreate("Hello…

AutoIt Scripting Language and SDK - Part One

Definition – What is AutoIt ?

 AutoIt is a freeware automation language for Microsoft Windows. In its earliest release, the software was primarily intended to create automation scripts (sometimes called macros) for Microsoft Windows programs but has since grown to include enhancements in both programming language design and overall functionality.AutoIt is a language made for automating the functionalities under Microsoft windows to automate repetitive tasks. E.g. Installation/Un-installation of software, monitoring and triggering batch jobs and tasks, and repetitive test case executions.History
 Developer(s) : Jonathan Bennett & AutoIt Team Stable release : / December 24th, 2008 lPreview release : / June 14th, 2009 Operating system : Microsoft Windows 95, 98, ME, NT4, 2000, XP, 2003 and Vista (however, support for operating systems older than Windows 2000 was discontinued with the release of v3.3.0)Type : GUI Scripting language Automation License : Freeware Website :…