Thursday, February 15, 2018

VBA Code to update test sets in ALM testlab

Hi All,
You might have come across scenarios where you are required to pass/fail many test cases in a test set. As ALM does not support bulk update, the easy way is to write a macro that does the job.Below is code for the same.





Sub ConnectToQualityCenter()
    Application.StatusBar = "Initiating connection"
    Dim qcURL As String
    Dim qcID As String
    Dim qcPWD As String
    Dim qcDomain As String
    Dim qcProject As String
    Dim tdConnection As Object
    Dim TestSetFact, tsTreeMgr, tSetFolder, TestSetsList, theTestSet
    Dim TestSetIdentifier, TSTestFact, TestSetTestsList, testInstanceF, aFilter
    Dim lst, tstInstance

    On Error GoTo err
    qcURL = "http://<XXXXX>.us.<XXXXX>.com/qcbin"
    qcID = Sheet1.Cells(2, 1)
    qcPWD = Sheet1.Cells(2, 2)
    If IsEmpty(qcID) Or IsEmpty(qcPWD) Then
        Application.StatusBar = "UID/PWD fields are mandatory"
        GoTo err2
    End If
    qcDomain = "<XXXXX>"
    qcProject = "<XXXXX>"

    'Display a message in Status bar
     Application.StatusBar = "Connecting to ALM..."
    'Create a Connection object to connect to Quality Center
      Set tdConnection = CreateObject("TDApiOle80.TDConnection")
    'Initialise the Quality center connection
       tdConnection.InitConnectionEx qcURL
    'Authenticating with username and password
       tdConnection.Login qcID, qcPWD
       Application.StatusBar = "Login successfull"
    'connecting to the domain and project
       tdConnection.Connect qcDomain, qcProject
    'On successfull login display message in Status bar
      Application.StatusBar = "Connection Established to <XXXXX>/<XXXXX>"


    '---------------------------------------Connection Established --------------------------------------------------------------------------
    ' Get the test set tree manager from the test set factory
    'tdconnection is the global TDConnection object.
    Set TSetFact = tdConnection.TestSetFactory
    Set tsTreeMgr = tdConnection.testsettreemanager
    ' Get the test set folder passed as an argument to the example code
    npath = Sheet1.Cells(2, 4)
    testSetName = Split(npath, "\")(UBound(Split(npath, "\")))
    npath = Replace(npath, testSetName, "")

    Set tsFolder = tsTreeMgr.NodeByPath(npath)
    '--------------------------------Check if the Path Exists or NOt ---------------------------------------------------------------------
    If tsFolder Is Nothing Then
        Application.StatusBar = "Invalid test set path"
    End If

    ' Search for the test set passed as an argument to the example code
    Set tsList = tsFolder.FindTestSets(testSetName)
    '----------------------------------Check if the Test Set Exists --------------------------------------------------------------------
    If tsList Is Nothing Then
        Application.StatusBar = "Invalid test set name"
    End If

    '---------------------------------------------Check if the TestSetExists or is Duplicated ----------------------------------------------
    If tsList.Count > 1 Then
        Application.StatusBar = "Found more than one test set:-> refine search"
        Exit Sub
    ElseIf tsList.Count < 1 Then
        Application.StatusBar = "Test set not found"
        Exit Sub
    End If

    '-------------------------------------------Access the Test Cases inside the Test SEt -------------------------------------------------

    allScriptsNames = ""
    usedrowsCounter = Sheet1.UsedRange.Rows.Count
    For rI = 2 To usedrowsCounter
        If IsEmpty(Sheet1.Cells(rI, 5)) Or IsEmpty(Sheet1.Cells(rI, 6)) Or InStr(1, allScriptsNames, Sheet1.Cells(rI, 5)) > 1 Then
        Else
            allScriptsNames = allScriptsNames & "##" & Sheet1.Cells(rI, 5) & "##" & Sheet1.Cells(rI, 6)
        End If
    Next

    Set theTestSet = tsList.Item(1)
    For Each testsetfound In tsList
        Set tsFolder = testsetfound.TestSetFolder
        Set tsTestFactory = testsetfound.tsTestFactory
        Set tsTestList = tsTestFactory.NewList("")
   
        For Each tsTest In tsTestList
            Application.StatusBar = tsTest.Name & tsTest.TestId
            testrunname = Sheet1.Cells(2, 3)
            If InStr(1, allScriptsNames, tsTest.Name + "##") > 1 Then
                'MsgBox Split(Split(allScriptsNames, tsTest.Name + "##")(1), "##")(0)
                '--------------------------------------------Accesss the Run Factory --------------------------------------------------------------------
                Set RunFactory = tsTest.RunFactory
                Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
                obj_theRun.Status = Split(Split(allScriptsNames, tsTest.Name + "##")(1), "##")(0)
                obj_theRun.Post
            End If
        Next tsTest
    Next testsetfound

err:

    tdConnection.Disconnect
    tdConnection.Logout
    tdConnection.ReleaseConnection
    Application.StatusBar = "Logged Out"
err2:
    If (err.Number <> 0) Then
        'Display the error message in Status bar
        Application.StatusBar = err.Description
    End If
End Sub

Function TimeStamp()
  Dim CurrTime
  CurrTime = Now()

  TimeStamp = CStr(Year(CurrTime)) & "-" _
    & LZ(Month(CurrTime)) & "-" _
    & LZ(Day(CurrTime)) & " " _
    & LZ(Hour(CurrTime)) & ":" _
    & LZ(Minute(CurrTime)) & ":" _
    & LZ(Second(CurrTime))
End Function

Thursday, February 8, 2018

You are becoming a dwarf or a giant?

Islands tend to create a paradoxical trend in evolution, which biologists call as "The Island rule" or "Foster's rule".
Something weird happens to animals when they cut themselves off from the mainland. To put it simply, large species such as elephants and hippos tend to get smaller if they spread to an island environment, while small species such as rodents and insects have a tendency to get bigger. Komodo dragon,elephant birds,dwarf mammoths, dwarf hippopotamuses,The mammoths of Wrangel Island and even Homo florescence are some examples of island rule.

In Island environments,whats different is that there are fewer predators and fewer competitors.
In Islands, small critters would face both fewer predators and fewer competitors, giving them plenty of space to get bigger. But big animals like elephants don't really worry much about predators or competitors, Their chief concern would be lack of resources to sustain themselves. For them, a smaller habitat means they have to be smaller to survive. The central factor that drives the changing size is energy consumption: all changes arise from the animal's energy needs, and how much energy it can gain in any given amount of time.So whatever benefit the change of size grants island animals, it's clearly significant enough to kick natural selection into overdrive.
Humans are social animals, so companies have almost same dynamics as in nature and natural selection implies.Based on the nature of work and operation model of a company and the employee strengths and weaknesses each employee can be related to some animal traits. what I strongly believe is that a best team composes employees of all natures so that its balanced. You cannot build a good team with all lions.
Critical responsibilities of leadership is making sure you have the right people in the right positions. You can have one of the most talented people in the world on your team but if you don’t put them in a position to succeed then their chance at success goes way way down. Albert Einstein said that “Everybody is a genius. But if you judge a fish by it’s ability to climb a tree, it will spend it’s whole life believing that it is stupid.” So it is with people too! You may not see all of your people as geniuses but each of them indeed has their own set of strengths and as a leader it is incumbent upon you to make certain that those strengths are put to good use.Too many leaders are almost completely unaware of the totality of their people’s strengths and that results in people locked into jobs that are often far below their abilities. Underutilized people become unmotivated people in the blink of an eye. If you don’t know what you have in your people you’ll likely never get it out of them. You run the risk of demotivating the very people you need to be as engaged as possible.
Not providing your people the opportunity to fully utilize their skills is one of the fastest ways to lose them. If you’re lucky once you lose them they will move on to greener pastures, if you’re not lucky then you’ll lose them and they will stay in your organization.
Companies/teams can be called Islands if they cant identify the strengths and weaknesses of their employees and healthy competition is not maintained.
So what are you becoming a dwarf or a giant, or working to the brink of your potential?
**Compilation !! - taken from multiple sources i read recently.