Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
46 changed files
with
29,585 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual C# Express 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QCIntegration", "QCIntegration\QCIntegration.csproj", "{AE12403C-E75D-4CBC-B93F-36845A2953CC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AE12403C-E75D-4CBC-B93F-36845A2953CC}.Debug|x86.ActiveCfg = Debug|x86 | ||
{AE12403C-E75D-4CBC-B93F-36845A2953CC}.Debug|x86.Build.0 = Debug|x86 | ||
{AE12403C-E75D-4CBC-B93F-36845A2953CC}.Release|x86.ActiveCfg = Release|x86 | ||
{AE12403C-E75D-4CBC-B93F-36845A2953CC}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<appSettings> | ||
<add key="qcHostname" value="qcserver.example.com"/> | ||
<add key="qcUrl" value="http://qcserver.example.com:8080/qcbin"/> | ||
<add key="qcDomain" value="myQCDomain"/> | ||
<add key="qcProject" value="myQCProject"/> | ||
<add key="qcLoginName" value="myQCLoginName"/> | ||
<add key="qcPassword" value="myQCPassword"/> | ||
|
||
<add key="qcPath" value="Root\myProject\myTestLab\myTestIterationFolder"/> | ||
<add key="qcTestSetName" value=""/> | ||
<add key="qcTestName" value=""/> | ||
|
||
<add key="testResultsFile" value="C:\temp\testresults.csv"/> | ||
<add key="delimiter" value=","/> | ||
|
||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
|
||
<targets> | ||
<target name="file" xsi:type="File" fileName="${basedir}/log.txt" /> | ||
<target name="console" xsi:type="Console" /> | ||
<target name="debug-console" xsi:type="Debug"/> | ||
</targets> | ||
|
||
<rules> | ||
<logger name="*" minlevel="Debug" writeTo="file" /> | ||
<logger name="*" minlevel="Trace" writeTo="console" /> | ||
<logger name="*" minlevel="Trace" writeTo="debug-console" /> | ||
</rules> | ||
</nlog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("QCIntegration")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("One Shore")] | ||
[assembly: AssemblyProduct("QCIntegration")] | ||
[assembly: AssemblyCopyright("Copyright © One Shore 2011")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("df234f27-3bb9-4989-8921-d568a08f73d7")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using TDAPIOLELib; | ||
using NLog; | ||
|
||
namespace oneshore.QCIntegration | ||
{ | ||
class QCController | ||
{ | ||
public string qcHostname { get; set; } | ||
public string qcDomain { get; set; } | ||
public string qcProject { get; set; } | ||
public string qcLoginName { get; set; } | ||
public string qcPassword { get; set; } | ||
public string qcUrl | ||
{ | ||
get | ||
{ | ||
if (qcUrl == null) { return "http://" + qcHostname + ":8080/qcbin"; } | ||
else { return qcUrl; } | ||
} | ||
set { qcUrl = value; } | ||
} | ||
|
||
public static string DELIM = "\t"; | ||
public int testCount { get; set; } | ||
|
||
private TDConnection tdConn; | ||
private string message; | ||
|
||
private static Logger log = NLog.LogManager.GetCurrentClassLogger(); | ||
|
||
/** | ||
* Constructor creates the Connection object | ||
* | ||
*/ | ||
public QCController() | ||
{ | ||
try | ||
{ | ||
this.tdConn = createTDConnection(); | ||
} | ||
catch (QCException e) | ||
{ | ||
log.Error(e.Message); | ||
throw; | ||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* create a new TDConnection object or throw QCException on failure | ||
* | ||
*/ | ||
public TDConnection createTDConnection() | ||
{ | ||
log.Debug("Creating TD connection."); | ||
|
||
TDConnection tdConn = new TDConnection(); | ||
|
||
if (tdConn == null) | ||
{ | ||
message = "Can't create TDConnection object -- maybe you need to reference TDAPIOLELib?"; | ||
throw new QCException(message); | ||
} | ||
|
||
return tdConn; | ||
} | ||
|
||
|
||
|
||
/** | ||
* Establish a connection to Quality Center | ||
* | ||
* @param string qcUrl | ||
* @param string qcDomain | ||
* @param string qcProject | ||
* @param string qcLoginName | ||
* @param string qcPassword | ||
* @return TDConnection | ||
*/ | ||
public TDConnection connectToQC(string qcUrl, string qcDomain, string qcProject, string qcLoginName, string qcPassword) | ||
{ | ||
try | ||
{ | ||
tdConn.InitConnectionEx(qcUrl); | ||
tdConn.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword); | ||
} | ||
catch (Exception e) | ||
{ | ||
log.Warn("unable to connect to project in QC"); | ||
log.Warn(e.Message); | ||
throw; | ||
} | ||
|
||
if (tdConn.Connected) | ||
{ | ||
message = "connected"; | ||
|
||
if (tdConn.ProjectConnected) | ||
{ | ||
message += " to QC project " + tdConn.ProjectName; | ||
log.Info(message); | ||
} | ||
else | ||
{ | ||
message += " to QC but unable to connect to QC Project " + qcProject; | ||
log.Warn(message); | ||
throw new QCException(message); | ||
} | ||
} | ||
else | ||
{ | ||
message = "failed to connect to QC"; | ||
log.Warn(message); | ||
throw new QCException(message); | ||
} | ||
|
||
return tdConn; | ||
} | ||
|
||
|
||
|
||
/** | ||
* find the test sets that will be updated in QC | ||
* | ||
* @param string tsPath | ||
* @param string tsName | ||
* @return List of TestSet | ||
*/ | ||
public List retrieveTestSets(string tsPath, string tsName) | ||
{ | ||
log.Debug("...in retriveTestSet() " + tsPath + " " + tsName); | ||
|
||
TestSetFolder tsFolder = retrieveFolder(tsPath); | ||
|
||
if (tsFolder == null) | ||
{ | ||
throw new QCException("no TestSetFolder at " + tsPath); | ||
} | ||
|
||
List tsList = tsFolder.FindTestSets(tsName, false, null); | ||
|
||
if (tsList == null) | ||
{ | ||
throw new QCException("no TestSets matching " + tsName); | ||
} | ||
|
||
if (tsList.Count < 1) | ||
{ | ||
throw new QCException("no TestSets found matching " + tsName); | ||
} | ||
|
||
return tsList; | ||
} | ||
|
||
|
||
|
||
/*** | ||
* get one or more tests that matches a specific test case name | ||
* | ||
* @param string tsFolderName | ||
* @param string tsTestName | ||
* @return List of TsTest | ||
*/ | ||
public List retrieveTests(string tsFolderName, string tsTestName) | ||
{ | ||
TestSetFolder tsFolder = retrieveFolder(tsFolderName); | ||
log.Debug("tsFolder.Path: " + tsFolder.Path); | ||
|
||
List tsTestList = tsFolder.FindTestInstances(tsTestName, false, null); | ||
return tsTestList; | ||
} | ||
|
||
|
||
|
||
/** | ||
* get a folder in QC | ||
* | ||
* @param string tsPath | ||
* @return TestSetFolder | ||
*/ | ||
public TestSetFolder retrieveFolder(string tsPath) | ||
{ | ||
TestSetFactory tsFactory = (TestSetFactory)tdConn.TestSetFactory; | ||
TestSetTreeManager tsTreeMgr = (TestSetTreeManager)tdConn.TestSetTreeManager; | ||
|
||
TestSetFolder tsFolder = null; | ||
try | ||
{ | ||
tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(tsPath); | ||
} | ||
catch (Exception e) | ||
{ | ||
log.Warn("couldn't get TestSetFolder with path " + tsPath); | ||
log.Warn(e.Message); | ||
} | ||
|
||
return tsFolder; | ||
} | ||
|
||
|
||
/** | ||
* set status for tests in a test set and update in QC | ||
* | ||
* @param TestSet testSet | ||
* @param Dictionary<string, string> testResults - testCaseName, testResult (e.g. "EHR_REF_PAT_0001", "Passed") | ||
*/ | ||
public void recordTestSetResults(TestSet testSet, Dictionary<string, string> testResults) | ||
{ | ||
TestSetFolder tsFolder = (TestSetFolder)testSet.TestSetFolder; | ||
log.Debug("tsFolder.Path: " + tsFolder.Path); | ||
|
||
string testSetInfo = "testSet.ID: " + testSet.ID.ToString() + DELIM + | ||
"testSet.Name: " + testSet.Name + DELIM + | ||
"testSet.Status: " + testSet.Status + DELIM + | ||
""; | ||
|
||
log.Debug("testSetInfo: " + testSetInfo); | ||
|
||
TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory; | ||
List tsTestList = tsTestFactory.NewList(""); | ||
|
||
foreach (TSTest tsTest in tsTestList) | ||
{ | ||
testCount++; | ||
|
||
string testInfo = DELIM + DELIM + DELIM + | ||
"TestId: " + tsTest.TestId + DELIM + | ||
"TestName: " + tsTest.TestName + DELIM + | ||
""; | ||
|
||
Run lastRun = (Run)tsTest.LastRun; | ||
if (lastRun != null) | ||
{ | ||
testInfo += lastRun.Name + DELIM + lastRun.Status; | ||
} | ||
|
||
log.Debug("TestInfo: " + testInfo); | ||
|
||
// look for a test in the results from this test set | ||
if (testResults.ContainsKey(tsTest.TestName)) | ||
{ | ||
string status = testResults[tsTest.TestName]; | ||
recordTestResult(tsTest, status); | ||
} | ||
|
||
} | ||
} | ||
|
||
|
||
|
||
/** | ||
* set status for a single test and update in QC | ||
* | ||
* @param TSTest test - the test to be updated | ||
* @param string status - "Passed", "Failed", etc. | ||
*/ | ||
public void recordTestResult(TSTest test, string status) | ||
{ | ||
string testInfo = DELIM + DELIM + DELIM + | ||
"TestId: " + test.TestId + DELIM + | ||
"TestName: " + test.TestName + DELIM + | ||
""; | ||
|
||
Run lastRun = (Run)test.LastRun; | ||
if (lastRun != null) | ||
{ | ||
testInfo += lastRun.Name + DELIM + lastRun.Status; | ||
} | ||
|
||
log.Debug(testInfo); | ||
|
||
RunFactory runFactory = (RunFactory)test.RunFactory; | ||
String date = DateTime.Now.ToString("yyyyMMddhhmmss"); | ||
Run run = (Run)runFactory.AddItem("Run" + date); | ||
run.Status = status; | ||
run.Post(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace oneshore.QCIntegration | ||
{ | ||
public class QCException : ApplicationException | ||
{ | ||
public QCException(string message) : base(message) | ||
{} | ||
} | ||
} |
Oops, something went wrong.