Respected Contributor.
Respected Contributor.
207 views

Is it possible to run test set using REST API

Hi.

Is it possible to run test set using REST API. We use ALM 15. I found some examples using rest/.../startruntestset but it not works for me (get 302 response code).

Tnx for any answer

Regards

9 Replies
Highlighted
Respected Contributor.. Respected Contributor..
Respected Contributor..

Re: Is it possible to run test set using REST API

Hello dkoci,

REST API can create, read, update, and delete data on the ALM, but not execute. 

To execute you might want to use OTA API, please see below example taken for this guide: 

https://admhelp.microfocus.com/alm/api_refs/ota/Default.htm#ota/topic3.html%3FTocPath%3D_____1

Public Sub RunTestSet(tsFolderName As String, tSetName As String, _
        HostName As String, runWhere As Integer)

' Run the test instances in a test set locally, remotely, or as planned
' Get status information when running a test set

' This example show how to run a test set in three different ways:
' * Run all tests on the local machine (where this code runs).
' * Run the tests on a specified remote machine.
' * Run the tests on the hosts as planned in the test set.
    Dim TSetFact As TestSetFactory, tsList As List
    Dim theTestSet As TestSet
    Dim tsTreeMgr As TestSetTreeManager
    Dim tsFolder As TestSetFolder
    Dim Scheduler As TSScheduler
    Dim execStatus As ExecutionStatus
    
    On Error GoTo RunTestSetErr
    errmsg = "RunTestSet"
' Get the test set tree manager from the test set factory.
    'tdc is the global TDConnection object.
    Set TSetFact = tdc.TestSetFactory
    Set tsTreeMgr = tdc.TestSetTreeManager
' Get the test set folder passed as an argument to the example code.
    Dim nPath$
    nPath = "Root\" & Trim(tsFolderName)
    On Error Resume Next
    Set tsFolder = tsTreeMgr.NodeByPath(nPath)
 
    If tsFolder Is Nothing Then
        err.Raise vbObjectError + 1, "RunTestSet", "Could not find folder " & nPath
        GoTo RunTestSetErr
    End If
    On Error GoTo RunTestSetErr
' Search for the test set passed as an argument to the example code.
    Set tsList = tsFolder.FindTestSets(tSetName)
    If tsList.Count > 1 Then
        MsgBox "FindTestSets found more than one test set: refine search"
    ElseIf tsList.Count < 1 Then
        MsgBox "FindTestSets: test set not found"
    End If
    
    Set theTestSet = tsList.Item(1)
    Debug.Print theTestSet.ID

' Start the scheduler on the local machine.
    Set Scheduler = theTestSet.StartExecution("")

'Set up for the run depending on where the test instances
' are to execute.
    
    Select Case runWhere
        
        Case RUN_LOCAL
        ' Run all tests on the local machine.
            Scheduler.RunAllLocally = True
        Case RUN_REMOTE
        ' Run tests on a specified remote machine.
            Scheduler.TdHostName = HostName
            ' RunAllLocally must not be set for
            ' remote invocation of tests.
            ' Do not do this:
            ' Scheduler.RunAllLocally = False
        Case RUN_PLANNED_HOST
        ' Run on the hosts as planned in the test set.
            Dim TSTestFact As TSTestFactory, testList As List
            Dim tsFilter As TDFilter
            Dim TSTst As TSTest
        ' Get the test instances from the test set.
            Set TSTestFact = theTestSet.TSTestFactory
            Set tsFilter = TSTestFact.Filter
            tsFilter.Filter("TC_CYCLE_ID") = theTestSet.ID
            Set testList = TSTestFact.NewList(tsFilter.Text)
            Debug.Print "Test instances and planned hosts:"
        'For each test instance, set the host to run depending
        '  on the planning in the test set.
            For Each TSTst In testList
                Debug.Print "Name: " & TSTst.Name & " ID: " & TSTst.ID & " Planned Host: " & TSTst.HostName
                Scheduler.RunOnHost(TSTst.ID) = TSTst.HostName
            Next TSTst
    
            Scheduler.RunAllLocally = False
    End Select
' Run the tests.
    Scheduler.Run
' Get the execution status object.
    Set execStatus = Scheduler.ExecutionStatus
' Track the events and statuses.
    Dim RunFinished As Boolean, iter As Integer, i As Integer
    Dim ExecEventInfoObj As ExecEventInfo, EventsList As List
    Dim TestExecStatusObj As TestExecStatus
    While ((RunFinished = False) And (iter < 100))
        iter = iter + 1
        execStatus.RefreshExecStatusInfo "all", True
        RunFinished = execStatus.Finished
        Set EventsList = execStatus.EventsList
   
        For Each ExecEventInfoObj In EventsList
            Debug.Print Tab; "Event: " & ExecEventInfoObj.EventDate & " " & _
                    ExecEventInfoObj.EventTime & " " & _
                    "Event Type: " & ExecEventInfoObj.EventType & " [Event types: " & _
                    "1-fail, 2-finished, 3-env fail, 4-timeout, 5-manual]"
        Next
        
        Debug.Print Tab; execStatus.Count & " exec status"
        For i = 1 To execStatus.Count
            Set TestExecStatusObj = execStatus.Item(i)
            Debug.Print Tab; "Iteration " & iter & " Status: " & _
                        " Test " & TestExecStatusObj.testID & _
                        " ,Test instance " & TestExecStatusObj.TestInstance & _
                        " ,order " & TestExecStatusObj.TSTestID & " " & _
                        TestExecStatusObj.Message & ", status=" & _
                        TestExecStatusObj.Status
        Next i
        'Sleep() has to be declared before it can be used.
        'This is the module level declaration of Sleep():
        'Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
        Sleep (5000)
        
    Wend 'Loop While execStatus.Finished = False
  
    Debug.Print "Scheduler finished around " & CStr(Now)
    Debug.Print
    
Exit Sub
RunTestSetErr:
' Handle error
End Sub  

 

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: Is it possible to run test set using REST API

Thank you for your answer. Is it possible to use OTA API in Java? We have web application and we need to run test set fron that application. Is it possible in java (backend) webapp and OTA API?
0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Is it possible to run test set using REST API

Can you share the reason why you want to do so? Do you want to upload test results or trigger tests stored in ALM? There are probably better solutions.

Highlighted
Respected Contributor.
Respected Contributor.

Re: Is it possible to run test set using REST API

I have tests stored in ALM. I also have test set which i would like to run with rest api. I develope some mobile app which will allow me to run test set without opening ALM, login into it. I would like to simply press button in my mobile app which would triger 'RUN test-set' in ALM.
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Is it possible to run test set using REST API

If you work with Jenkins, then Micro Focus Automation Tools Plugin is a good choice.

Your server side can simply trigger Jenkins job to execute tests.

0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: Is it possible to run test set using REST API

I found exactly what I want: https://eyeonquality.com/kicking-off-alm-lab-management-test-runs-via-rest-api/

But unfortunately it doesnt work on new ALM anymore. Is there any reason why Microfocus have removed this operation? Disapointed.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Is it possible to run test set using REST API

This is not a built-in feature in ALM, it is provided by Lab Management extension.

So the REST API is still there but you have to enable Lab Management extension. 

0 Likes
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

Re: Is it possible to run test set using REST API

Based on your description, I think you just want to run tests "manually" from the mobile device (trigger test, read steps, mark status, and stop run),  if this is what you want precisely, please try this: https://marketplace.microfocus.com/appdelivery/content/alm-quality-of-things-qot

Suggest to run it on pad, the UI is designed for phone. It has offline execution function, you can download your test sets, run without ALM connection, and then upload test results.

Highlighted
Respected Contributor.
Respected Contributor.

Re: Is it possible to run test set using REST API

ALM QoT is ok for manual tests. But I need to trigger functional tests which.
Finally I have a working solution with rest api. I can past some instructions if you are interested.
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.