Интеграция TestComplete и HP Quality Center

Вы еще не интегрировали TestComplete с HP Quality Center? А вот ребята из SmartBear эту проблему уже решали, а именно:

  1. Подсоединиться к HP Quality Center.
  2. Создать test set
  3. Добавить test case к test set.
  4. Выложить результаты test case
  5. Прикрепить логи пронона к test set
  6. Отсоединиться от HP Quality Center
Скрипты для этих шагов указанны ниже:

Подсоединиться к HP Quality Center или Отсоединиться от HP Quality Center

{syntaxhighlighter brush: jscript;fontsize: 100; first-line: 1; }function Connect (host, domain, project, user, password) { eval (Project.variables.functionEnter); returnCode_ = null; try { tdc_ = Sys.OleObject ('TDApiOle80.TDConnection'); tdc_.InitConnectionEx (host); tdc_.ConnectProjectEx (domain, project, user, password); } catch (exception) { returnCode_ = exception.description; } }{/syntaxhighlighter}

Создать test set

{syntaxhighlighter brush: jscript;fontsize: 100; first-line: 1; }var treeManager = tdc_.TestSetTreeManager; var testSetFactory = tdc_.TestSetFactory;

var testSetFolder = treeManager.NodeByPath (testSetFolderName);
var testSet = testSetFactory.AddItem (testSetName);
testSet.TestSetFolder = testSetFolder;
testSet.Field (‘CY_COMMENT’) = testSetComment;
testSet.Post ();{/syntaxhighlighter}

Выложить результаты test case

{syntaxhighlighter brush: jscript;fontsize: 100; first-line: 1; }// Start of Test

var startTime = aqDateTime.Now();
var errorCountBefore = Log.ErrCount;

TestCase ();

// End of Test
var endTime = aqDateTime.Now ();
var totalTime = aqDateTime.TimeInterval (endTime, startTime);
totalTime = (aqDateTime.GetSeconds(totalTime)) + (aqDateTime.GetMinutes(totalTime) * 60) + (aqDateTime.GetHours(totalTime) * 60 * 60);

errorCountAfter = Log.ErrCount; var result = (errorCountBefore == errorCountAfter) ? ‘Passed’ : ‘Failed’;

QualityCenter.PostTestRun (myTestRun, result, totalTime);{/syntaxhighlighter}{syntaxhighlighter brush: jscript;fontsize: 100; first-line: 1; }Log.SaveResultsAs (resultsDir, lsHTML);
var fileList = slPacker.GetFileListFromFolder (resultsDir);
if (slPacker.Pack (fileList, resultsDir, resultsZip))
{
QualityCenter.CloseTestSet (myTestSet, resultsZip);
}
else
{
Log.Error (‘Error archiving files.’);{/syntaxhighlighter}

Полный скрипт

{syntaxhighlighter brush: jscript;fontsize: 100; first-line: 1; }function QualityCenterSample ()
{
var host = ‘http://url//qcbin’;
var domain = ‘myDomain’;
var project = ‘myProject’;
var user = ‘UserName’;
var password = ‘ThisIsABadPassword’;

var testSetFolder = ‘Root\Test Lab Folder 1\Folder2’
var testSetName = ‘TestComplete Tests’;
var testSetComment = ‘Created by TestComplete’;
var testCase = ‘Subject\Test Plan Folder 1\Folder 2\Test Case’;
var testRunName = ‘TestComplete automated test run’;

var resultsDir = ‘C:\temp\results’;
var resultsZip = ‘C:\temp\TestCompleteLog.zip’;

QualityCenter.Connect (host, domain, project, user, password);
if (QualityCenter.returnCode != null)
{ /* Deal with failure to connect. */ }

var myTestSet = QualityCenter.NewTestSet (testSetFolder, testSetName, testSetComment);
if (QualityCenter.returnCode != null)
{ /* Deal with failure to create test set. */ }

var myTestCase = QualityCenter.GetTestCase (testCase);
if (QualityCenter.returnCode != null)
{ /* Deal with failure to get a test case. */ }

var myTestRun = QualityCenter.AddRunToTestSet(myTestSet, myTestCase, testRunName);
if (QualityCenter.returnCode != null)
{ /* Deal with failure to add test run. */ }

// Start of Test
var startTime = aqDateTime.Now();
var errorCountBefore = Log.ErrCount;

TestCaseSample ();

// End of Test
var endTime = aqDateTime.Now ();
var totalTime = aqDateTime.TimeInterval (endTime, startTime);
totalTime = (aqDateTime.GetSeconds(totalTime)) + (aqDateTime.GetMinutes(totalTime) * 60)
+ (aqDateTime.GetHours(totalTime) * 60 * 60);

errorCountAfter = Log.ErrCount;
var result = (errorCountBefore == errorCountAfter) ? ‘Passed’ : ‘Failed’;

QualityCenter.PostTestRun (myTestRun, result, totalTime);
if (QualityCenter.returnCode != null)
{ /* Deal with failure to post result. */ }

Log.SaveResultsAs (resultsDir, lsHTML);
var fileList = slPacker.GetFileListFromFolder (resultsDir);
if (slPacker.Pack (fileList, resultsDir, resultsZip))
{
QualityCenter.CloseTestSet (myTestSet, resultsZip);
}
else
{
Log.Error (‘Error archiving files.’);
}

QualityCenter.Disconnect ();
}

function TestCaseSample ()
// I wish all test cases were this easy to write…
{
Delay (1000);
}{/syntaxhighlighter}

 

Источник: blog.smartbear.com