ALM OTA Wrapper API

ALM OTA Wrapper API is an helper API developed in C#.net for facilitating the development of applications interacting with HPE ALM.

Code for this api is available on Github.

Below are the examples of using this api for the development of applications.

Download Latest Version : Link is Coming Soon.

Login to ALM

Use the following code for login
ALM_Wrapper.ALM_CORE aLM_CORE = new ALM_Wrapper.ALM_CORE(); aLM_CORE.LoginALM(“ALMURL/qcbin”, “UserID”, “Password”, “Domain”, “Project”);
This will create the object of ALM Wrapper. This object will have access to different classes.

Test Plan Folders

Creating a Folder

TDAPIOLELib.TestFolder parent = aLM_CORE.TestPlan.TestFolders.Create(“Subject”, “Dummy1”);

Creating Mutiple folders

aLM_CORE.TestPlan.TestFolders.CreateNewFolderPath(“Subject\Dummy1\Dummy2\Dummy3”);

Find Child Folder Names

List list = aLM_CORE.TestPlan.TestFolders.GetChildFolderNames(“Subject\Dummy1”);
foreach (String folderName in list)
{
Console.WriteLine(“Folder Found under Subject\Dummy1 : ” + folderName);
}

Get TestFolder Object using Folder path

parent = aLM_CORE.TestPlan.TestFolders.GetFolderObject(“Subject\Dummy1\Dummy6”);
Console.WriteLine(“Count of folders under this folder is : ” + parent.TestFolderFactory.NewList(“”).Count);

Find Tests Under a Folder

TDAPIOLELib.List Tdlist = aLM_CORE.TestPlan.TestFolders.GetTests(“Subject\Dummy1\Dummy6”);
foreach (TDAPIOLELib.Test test in Tdlist)
{
Console.WriteLine(“Test Found under Subject\Dummy1\Dummy6 : ” + test.Name);
}

Rename a Folder

aLM_CORE.TestPlan.TestFolders.Rename(“Subject\Dummy1\Dummy6\Dummy7”, “Renamed7”); //Dummy7 Folder will be renamed ro Renamed7

Find All tests recursively (Including tests under any child folders)

TDAPIOLELib.List Tdlist = aLM_CORE.TestPlan.TestFolders.GetTestsRecurcively(“Subject\Dummy1\Dummy6”);
foreach (TDAPIOLELib.Test test in Tdlist)
{
Console.WriteLine(“After Renaming Folder Test Found Name : ” + test.Name + “, Path : ” + aLM_CORE.TestPlan.Test.GetPath(test));
}

Delete a folder

aLM_CORE.TestPlan.TestFolders.Delete(“Subject\Dummy1\Dummy6\Renamed7”, true);//Delete the folder and move tests to unattached

Tests in Test Plan

Create a new test

Dictionary<String, String> NewTest = new Dictionary<String, String>();
NewTest.Add(“TS_NAME”, “THIS IS DUMMUY TEST”);
NewTest.Add(“TS_STATUS”, “Ready”);
TDAPIOLELib.Test test = aLM_CORE.TestPlan.Test.Create(NewTest, “Subject\Dummy1”);

Add Design Steps with attachments

//Add Design steps
//Expected Values
List Expected = new List();
Expected.Add(“Step dummy 1”);
Expected.Add(“Step dummy 2”);

//Description values
List Desc = new List();
Desc.Add(“Step dummy 1 Desc”);
Desc.Add(“Step dummy 2 Desc”);

//Attachments for the design steps
List Attach = new List();
Attach.Add(@”C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(@”C:\Temp\ALMUPLOAD\DOC3.xlsx”);

aLM_CORE.TestPlan.Test.AddDesignSteps(test, Desc, Expected, Attach);

Uploading multiple attachments to design steps

List Attach = new List();
Attach.Add(@”C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(@”C:\Temp\ALMUPLOAD\DOC3.xlsx”);
TDAPIOLELib.DesignStep designStep = aLM_CORE.TestPlan.Test.AddSingleDeignStep(test, “Single Step”, “Nothing is expected”);
aLM_CORE.TestPlan.Test.AddAttachmentToDesignStep(designStep, Attach);

Add Single Test Parameters

aLM_CORE.TestPlan.Test.AddSingleParameter(test, “BrowserName”, “Chrome, IE, Firefox”, “Chrome”);

Add Multiple Test Parameters

List ParamName = new List();
ParamName.Add(“Browser”);
ParamName.Add(“URL”);

List ParamDescription = new List();
ParamDescription.Add(“Browser for executions”);
ParamDescription.Add(“URL to be used”);

List ParamDefaultVal = new List();
ParamDefaultVal.Add(“IE”);
ParamDefaultVal.Add(“Http://www.google.com“);

aLM_CORE.TestPlan.Test.AddParameters(test, ParamName, ParamDescription, ParamDefaultVal);

Find test Object With test ID

TDAPIOLELib.Test test = aLM_CORE.TestPlan.Test.GetObjectWithID(Convert.ToInt32(test.ID));

Get Design steps for test

TDAPIOLELib.List tdList = aLM_CORE.TestPlan.Test.GetDesignStepList(test);
foreach (TDAPIOLELib.DesignStep ODes in tdList)
{
Console.WriteLine(ODes.StepDescription + ” : ” + ODes.StepExpectedResult);
}

Add Attachments to test

List AttachmentsPath = new List();
AttachmentsPath.Add(@”C:\Temp\ALMUPLOAD\DOC1.txt”);
AttachmentsPath.Add(@”C:\Temp\ALMUPLOAD\DOC3.xlsx”);
AttachmentsPath.Add(@”C:\Temp\ALMUPLOAD\DOC2.docx”);
aLM_CORE.TestPlan.Test.AddAttachment(test, AttachmentsPath);

Download Test Attachments

aLM_CORE.TestPlan.Test.DownloadAttachments(test, “C:\Temp\ALMDOWNLOAD”);

Delete test attachments by name

aLM_CORE.TestPlan.Test.DeleteAttachmentByName(test, “DOC3.xlsx”);

Delete All test attachments

aLM_CORE.TestPlan.Test.DeleteAllAttachments(test);

Find the path of the test

Console.WriteLine(“Path of test case : ” + aLM_CORE.TestPlan.Test.GetPath(test));

Mark test as template

aLM_CORE.TestPlan.Test.MarkAsTemplate(test);

Update a field value

aLM_CORE.TestPlan.Test.UpdateFieldValue(test, “TS_STATUS”, “Design”);

Delete test

aLM_CORE.TestPlan.Test.Delete(test);

Find all tests under unattached

TDAPIOLELib.List Tdlist = aLM_CORE.TestPlan.Test.FindUnattachedTests();
foreach (TDAPIOLELib.Test Otest in Tdlist)
{
Console.WriteLine(“Tests from unattached : ” + Otest.Name);
}

Test Lab Folders

Create a Folder

aLM_CORE.TestLab.TestLabFolders.Create(“Root”, “Dummy1”);

Create a folder path (multiple folders)

aLM_CORE.TestLab.TestLabFolders.CreateNewFolderPath(“Root\Dummy1\Dummy2\Dummy3\Dummy4”);

Find folders under a test lab folder

List list = aLM_CORE.TestLab.TestLabFolders.FindChildFolders(“Root\Dummy1”);
foreach (String folderName in list)
{
Console.WriteLine(“Folder Under Root\Dummy\ : ” + folderName);
}

Find testsets under test lab folder

TDAPIOLELib.List tdList = aLM_CORE.TestLab.TestLabFolders.FindTestSets(“Root\Dummy1\Dummy2\Dummy3\Dummy4”);
foreach (TDAPIOLELib.TestSet testSet in tdList)
{
Console.WriteLine(“TestSets under Root\Dummy1\Dummy2\Dummy3\Dummy4 : ” + testSet.Name);
}

Get test lab folder object using path

TDAPIOLELib.TestSetFolder testSetFolder = aLM_CORE.TestLab.TestLabFolders.GetTestSetFolder(“Root\Dummy1\Dummy2\Dummy3\Dummy4”);
Console.WriteLine(“Parent Folder name : ” + testSetFolder.Father.Name.ToString());

Rename a test lab folder

aLM_CORE.TestLab.TestLabFolders.Rename(“Root\Dummy1\Dummy2\Dummy3”, “Dummy4”, “Renamed Dummy4”);

Delete a test lab folder

aLM_CORE.TestLab.TestLabFolders.Delete(“Root\Dummy1\Dummy2\Dummy3”, “Renamed Dummy4”);

TestSets

Create a testset

Dictionary<String, String> testSetDetails = new Dictionary<string, string>();
testSetDetails.Add(“CY_CYCLE”, “Dummy Test Set”);
TDAPIOLELib.TestSet testSet = aLM_CORE.TestLab.TestSet.Create(testSetDetails, “Root\Dummy1”);
Console.WriteLine(“Test Set created : ” + testSet.Name);

Add test to test set

aLM_CORE.TestLab.TestSet.AddTest(testSet, test); //test is the object of TDAPIOLELIB.Test.

Add all tests to test set from a test plan folder

aLM_CORE.TestLab.TestSet.AddAllTestsFromTestFolder(testSet, “Subject\Dummy2”);

Add Attachments to test set

List Attach = new List();
Attach.Add(“C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC3.xlsx”);
aLM_CORE.TestLab.TestSet.AddAttachments(testSet, Attach);

Pass all tests under a test set

aLM_CORE.TestLab.TestSet.PassAllTests(testSet);

Fail all tests under test set

aLM_CORE.TestLab.TestSet.FailAllTests(testSet);

Get tests instances

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);

Execute a test instance

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);
aLM_CORE.TestLab.TestSet.ExecuteSingleTest(TSTestList[1], “Not Completed”);

Update Custom execution status

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);
aLM_CORE.TestLab.TestSet.ExecuteSingleTest(TSTestList[1], “Not Completed”);
Console.WriteLine(“Executed First test from test set and marked it as Not Completed”);

Dictionary<int, String> executionList = new Dictionary<int, String>();
//Mark all tests as No Run
//Create the dictionary object for the test set
foreach (TDAPIOLELib.TSTest tSTest1 in TSTestList)
{
executionList.Add(Convert.ToInt32(tSTest1.ID), “No Run”);
}
aLM_CORE.TestLab.TestSet.ExecuteTests(executionList);
Console.WriteLine(“Changed status of all tests to No Run”);

Find test set with ID

TDAPIOLELib.TestSet testSet = aLM_CORE.TestLab.TestSet.GetObjectWithID(Convert.ToInt32(testSet.ID));

Find folder path for test set

aLM_CORE.TestLab.TestSet.GetFolderPath(testSet)

Find Test instances with ID

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);
TDAPIOLELib.TSTest tSTest = aLM_CORE.TestLab.TestSet.GetTSTestWithID(Convert.ToInt32(TSTestList[2].ID));
Console.WriteLine(“Found Second Test Object from test set : ” + tSTest.TestName);

Get Run details for test instance

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);
TDAPIOLELib.Run run = aLM_CORE.TestLab.TestSet.GetLastRunDetails(TSTestList[1]);
Console.WriteLine(“Got last run details for test set test : ” + run.Name + ” : ” + run.ID);

Remove test instance from test set

TDAPIOLELib.List TSTestList = aLM_CORE.TestLab.TestSet.GetAllTestInstance(testSet);
aLM_CORE.TestLab.TestSet.RemoveTest(testSet, TSTestList[1]);

Remove all test instances from test set

aLM_CORE.TestLab.TestSet.RemoveAllTests(testSet);

Download test set attachments

aLM_CORE.TestLab.TestSet.DownloadAttachements(testSet, “C:\Temp\ALMDOWNLOAD”);

Delete test set attachment by name

aLM_CORE.TestLab.TestSet.DeleteAttachmentByName(testSet, “DOC1.txt”);

Delete all test set attachments

aLM_CORE.TestLab.TestSet.DeleteAllAttachments(testSet);

Find unattached test sets

TDAPIOLELib.List unattachedTestSetsList = aLM_CORE.TestLab.TestSet.FindUnattachedTestSets();
foreach (TDAPIOLELib.TestSet unattachedTestSets in unattachedTestSetsList)
{
Console.WriteLine(unattachedTestSets.Name);
}

Update a field value

aLM_CORE.TestLab.TestSet.UpdateFieldValue(testSet, “CY_STATUS”, “Closed”);

Delete a test set

aLM_CORE.TestLab.TestSet.Delete(testSet);

Defects

Create a defect

//You will have to add all mandatory fields here
Dictionary<String, String> defectDetails = new Dictionary<string, string>();
defectDetails.Add(“BG_SUMMARY”, “Defect created using Automation”);
defectDetails.Add(“BG_SEVERITY”, “3”);
defectDetails.Add(“BG_DETECTED_BY”, “ALMUSER”);
TDAPIOLELib.Bug bug = aLM_CORE.Defect.Create(defectDetails);

Count all defects

aLM_CORE.Defect.CountAll()

Find defect details

TDAPIOLELib.Recordset ORec = aLM_CORE.Defect.GetAllDetails(bug);
Console.WriteLine(“Writing all Database field names and values…”);
for (int i = 0; i < ORec.RecordCount; i++)
{
for (int j = 0; j < ORec.ColCount; j++)
{
Console.WriteLine(ORec.ColName[j] + “–” + ORec[j]);
}
ORec.Next();
}

Link defect to test

aLM_CORE.Defect.LinkDefectToTest(test, bug, “Linking defect to test”);

Link defect to test set

aLM_CORE.Defect.LinkDefectToTestSet(testSet, bug, “Test Set to Bug Linked”);

Link defect to test instance under a test set

TDAPIOLELib.TSTest tSTest = aLM_CORE.TestLab.TestSet.AddTest(testSet, test);
aLM_CORE.Defect.LinkDefectToTestSetTest(tSTest, bug, “Test Set Test to Bug Linked”);

Find Linked defects to a test

TDAPIOLELib.List list = aLM_CORE.Defect.GetLinkedDefectsToTest(test);
foreach (TDAPIOLELib.Bug bug1 in list)
{
Console.WriteLine(“Defect Attached to test is : ” + bug1.Summary);
}

Find defects linked to test set

list = aLM_CORE.Defect.GetLinkedDefectsToTestSet(testSet);
foreach (TDAPIOLELib.Bug bug1 in list)
{
Console.WriteLine(“Defect Attached to testset is : ” + bug1.Summary);
}

Find defects linked to test instances under test set

list = aLM_CORE.Defect.GetLinkedDefectsToTestSetTest(tSTest);
foreach (TDAPIOLELib.Bug bug1 in list)
{
Console.WriteLine(“Defect Attached to testset test is : ” + bug1.Summary);
}

Add attachments to defects

List Attach = new List();
Attach.Add(“C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC3.xlsx”);
aLM_CORE.Defect.AddAttachment(bug, Attach);

Download all attachments

aLM_CORE.Defect.DownloadAttachments(bug, “C:\Temp\ALMDOWNLOAD”);

Delete attachment by name

aLM_CORE.Defect.DeleteAttachmentByName(bug, “DOC2.docx”);

Delete all attachments

aLM_CORE.Defect.DeleteAllAttachments(bug);

Update field value

aLM_CORE.Defect.UpdateFieldValue(bug, “BG_STATUS”, “Closed”);

Find defect with ID

bug = aLM_CORE.Defect.GetObjectWithID(Convert.ToInt32(bug_ID));

Delete a defect

aLM_CORE.Defect.Delete(bug);

Release Folders

Create a folder

TDAPIOLELib.ReleaseFolder releaseFolder = aLM_CORE.Releases.ReleaseFolders.Create(“Releases\Dummy1”, “Dummy2”);

Create a folder path (Multiple Folders)

TDAPIOLELib.ReleaseFolder releaseFolder1 = aLM_CORE.Releases.ReleaseFolders.CreateNewFolderPath(“Releases\Dummy1\Dummy2\Dummy3\Dummy4\Dummy6”);

Add attachments to release folders

List Attach = new List();
Attach.Add(“C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC3.xlsx”);
aLM_CORE.Releases.ReleaseFolders.AddAttachment(releaseFolder, Attach);

Delete attachment by name

aLM_CORE.Releases.ReleaseFolders.DeleteAttachmentByName(releaseFolder, “DOC1.txt”);

Delete all attachments

aLM_CORE.Releases.ReleaseFolders.DeleteAllAttachments(releaseFolder);

Get child folder names

foreach (String folderNames in aLM_CORE.Releases.ReleaseFolders.GetChildFolderNames(“Releases”))
{
Console.WriteLine(folderNames);
}

Get child folder objects

foreach (TDAPIOLELib.ReleaseFolder releasef in aLM_CORE.Releases.ReleaseFolders.GetChildFolders(aLM_CORE.Releases.ReleaseFolders.GetNodeObject(“Releases\Dummy1\Dummy2\Dummy3\Dummy4”)))
{
Console.WriteLine(releasef.Name);
}

Get Child folder object with name

TDAPIOLELib.ReleaseFolder releaseFolder1 = aLM_CORE.Releases.ReleaseFolders.GetChildFolderWithName(aLM_CORE.Releases.ReleaseFolders.GetNodeObject(“Releases\Dummy1”), “Dummy2”);

Get path of release folder

TDAPIOLELib.ReleaseFolder releaseFolder1 = aLM_CORE.Releases.ReleaseFolders.GetChildFolderWithName(aLM_CORE.Releases.ReleaseFolders.GetNodeObject(“Releases\Dummy1”), “Dummy2”);
Console.WriteLine(“Path of the releaseFolder1 : ” + aLM_CORE.Releases.ReleaseFolders.GetPath(releaseFolder1));

Rename a release folder

aLM_CORE.Releases.ReleaseFolders.Rename(releaseFolder1, “Dummy Renamed”);

Find releases under folder

foreach (TDAPIOLELib.Release release in aLM_CORE.Releases.ReleaseFolders.GetReleases(aLM_CORE.Releases.ReleaseFolders.GetNodeObject(“Releases\Dummy”)))
{
Console.WriteLine(“Release Name : ” + release.Name);
}

Delete a release folder

aLM_CORE.Releases.ReleaseFolders.Delete(“Releases\Dummy1”, “Dummy2”);

Releases

Create a new release

Dictionary<String, String> releaseDetails = new Dictionary<string, string>();
TDAPIOLELib.ReleaseFolder releaseFolder = aLM_CORE.Releases.ReleaseFolders.Create(“Releases”, “Dummy1”);
releaseDetails.Add(“REL_NAME”, “Release1”);
releaseDetails.Add(“REL_START_DATE”, DateTime.Now.ToShortDateString());
releaseDetails.Add(“REL_END_DATE”, DateTime.Now.AddDays(10).ToShortDateString());
TDAPIOLELib.Release release = aLM_CORE.Releases.Release.Create(releaseDetails, aLM_CORE.Releases.ReleaseFolders.GetPath(releaseFolder));

Add attachments to release

List Attach = new List();
Attach.Add(“C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC3.xlsx”);
aLM_CORE.Releases.Release.AddAttachment(release, Attach);

Download attachments

aLM_CORE.Releases.Release.DownloadAttachments(release, “C:\Temp\ALMDOWNLOAD”);

Delete attachment by name

aLM_CORE.Releases.Release.DeleteAttachmentByName(release, “DOC3.xlsx”);

Delete all attachments

Console.WriteLine(“Path of release : ” + aLM_CORE.Releases.Release.GetPath(release));

Get Cycles for release

foreach (TDAPIOLELib.Cycle cycle in aLM_CORE.Releases.Release.GetCycles(aLM_CORE.Releases.ReleaseFolders.GetReleaseByName(aLM_CORE.Releases.ReleaseFolders.GetNodeObject(“Releases\Dummy”), “Test123”)))
{
Console.WriteLine(“Cycle Name : ” + cycle.Name);
}

Delete a release

aLM_CORE.Releases.Release.Delete(release);

Cycles

Create a Cycle

Dictionary<String, String> releaseDetails = new Dictionary<string, string>();
TDAPIOLELib.ReleaseFolder releaseFolder = aLM_CORE.Releases.ReleaseFolders.Create(“Releases”, “Dummy1”);
releaseDetails.Add(“REL_NAME”, “Release1”);
releaseDetails.Add(“REL_START_DATE”, DateTime.Now.ToShortDateString());
releaseDetails.Add(“REL_END_DATE”, DateTime.Now.AddDays(10).ToShortDateString());
TDAPIOLELib.Release release = aLM_CORE.Releases.Release.Create(releaseDetails, aLM_CORE.Releases.ReleaseFolders.GetPath(releaseFolder));
TDAPIOLELib.Cycle cycle = aLM_CORE.Releases.Cycle.Create(“Cycle1”, release.StartDate, release.EndDate, release);

Add attachments

List Attach = new List();
Attach.Add(“C:\Temp\ALMUPLOAD\DOC1.txt”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC2.docx”);
Attach.Add(“C:\Temp\ALMUPLOAD\DOC3.xlsx”);
aLM_CORE.Releases.Cycle.AddAttachment(cycle, Attach);

Download attachments

aLM_CORE.Releases.Cycle.DownloadAttachments(cycle, “C:\Temp\ALMDOWNLOAD”);

Delete Attachments by name

aLM_CORE.Releases.Cycle.DeleteAttachmentByName(cycle, “DOC1.txt”);

Delete all attachments

aLM_CORE.Releases.Cycle.DeleteAllAttachments(cycle);

Get all Cycle details

TDAPIOLELib.Recordset ORec = aLM_CORE.Releases.Cycle.GetAllDetails(cycle);
for (int i = 0; i < ORec.RecordCount; i++)
{
for (int j = 0; j < ORec.ColCount; j++)
{
Console.WriteLine(ORec.ColName[j] + “–” + ORec[j]);
}
ORec.Next();
}

Find release for Cycle

TDAPIOLELib.Release release = aLM_CORE.Releases.Cycle.GetRelease(cycle); Console.WriteLine(release.Name);

Delete a Cycle

aLM_CORE.Releases.Cycle.Delete(cycle);

Advertisement

One response to “ALM OTA Wrapper API

  1. Hi Sumeet,
    Could you please help me in downloading the test cases with steps
    in excel format from HP ALM 12 for a selected domain/project/folder or all folders under a selected project.

    It would of great help if you can provide any utility or working code

    Thanks & Regards,
    Marraju

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s