<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../../../CSS/bootstrap/bootstrap.min.css" rel="stylesheet" />
<!--如果有修改该配置文件,请修改"?"号后面的参数-->
<script src="../../../Scripts/config.js?v=1.1"></script>
<script src="../../../Scripts/Base64.js"></script>
<script src="../../../Scripts/jquery/jquery-1.10.2.min.js"></script>
<script src="../../../Scripts/bootstrap.min.js"></script>
<script src="../../../Scripts/jquery.form.js"></script>
<script type="text/javascript">
var url = "http://localhost";
$(function () {
//导出数据
$("#BtnExport").click(exportData);
$("#BtnCaseSuit").click(CaseSuit);
$("#BtnCaseSearch").click(CaseSearch);
$("#BtnWorkItemDetails").click(getWorkItemDetails);
$("#BtnUpdateTestCaseResult").click(updateTestCaseResult);
$("#BtnGetDetailsOfTestCase").click(GetDetailsOfTestCase);
});
//修改执行用例的测试结果
function updateTestCaseResult() {
var json = {
CollectionName: '项间需求2',
ProjectName: '项间需求项目2',
TestRunid: '218',
TestCaseResultInfo: {
ComputerName: "1",
FailureType: "2",
FailureTypeId: "0",
Priority: "1",
State: "5",
TestCaseRevision: "2",
Comment: "此处为注释",
DateCompleted: "2016-5-9",
DateStarted: "2015-5-5",
ErrorMessage: "错误信息",
Outcome: "3"
}
};
$.ajax({
type: "post",
url: "http://localhost:8080/TfsWebApi/api/TestDoCase/UpdateTestResult",
data: JSON.stringify(json),
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
alert(data);
}
});
}
//查询工作项详情
function getWorkItemDetails() {
$.ajax({
type: "post",
url: "http://localhost/TfsWebApi/api/WorkItem/GetDetailsOfWorkItem",
data: "{'collectionName':'项间需求2','projectName':'项间需求项目2',id:'218'}",
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
alert(data);
}
});
}
//计划
function exportData() {
$.ajax({
type: "post",
url: "http://localhost/TfsWebApi/api/TestPlan/GetTestPlan",
data: "{'collectionName':'WX201512','projectName':'WX20151207'}",
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
var value = "";
$(eval(data)).each(function () {
value += "【id:" + this.id
+ "; name:" + this.name
+ "; Areapath:" + this.Areapath
+ "; Iteration:" + this.Iteration
+ "; Description:" + this.Description
+ "; StartDate:" + this.StartDate
+ "; EndTime:" + this.EndTime
+ "; Description:" + this.Description
+ ";Links:" + this.Links
+ ";State:" + this.State
+ "】<br/>";
});
$("#valuesshow").html(value);
}
});
}
//根据测试计划查询测试套件
function CaseSuit() {
$.ajax({
type: "post",
url: "http://localhost:8080/TfsWebApi/api/TestSuit/GetTestSuitFromPlan",
data: "{'collectionName':'WX201512','projectName':'WX20151207','testPlanIds':'251,428,436'}",
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
var value = "";
$(eval(data)).each(function () {
value += "【planid:" + this.planId
+ "; id:" + this.id
+ "; title:" + this.Title
+ "; State:" + this.State
+ "; Description: " + this.Description
+ "】<br/>";
});
$("#valuesshow").html(value);
}
});
}
//根据测试套件查询执行用例
function CaseSearch() {
$.ajax({
type: "post",
url: "http://localhost/TfsWebApi/api/TestDoCase/GetTestDoCaseFromSuit",
data: "{'collectionName':'WX201512','projectName':'WX20151207','testSuitids':'252,253,307','testPlanIds':'428,436'}",
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
var value = "";
$(eval(data)).each(function () {
value += "【planId:" + this.planId
+ "; planName:" + this.planName
+ "; suitId:" + this.suitId
+ "; suitName:" + this.suitName
+ "; testCaseId:" + this.testCaseId
+ "; testCaseName:" + this.testCaseName
+ "; testRunId:" + this.testRunId
+ "; testRunDateDue:" + this.testRunDateDue
+ "; testRunState:" + this.testRunState
+ "; testRunTime:" + this.testRunTime
+ "; testRunMan:" + this.testRunMan
+ "; buglinks:" + this.buglinks
+ "】<br/>";
});
$("#valuesshow").html(value);
}
});
}
//查询用例详情
function GetDetailsOfTestCase() {
$.ajax({
type: "post",
url: "http://localhost:8080/TfsWebApi/api/TestCase/GetDetailsOfTestCase",
data: "{'collectionName':'项间需求2','projectName':'项间需求项目2','testCaseIds':'332,351,352,362,363'}",
contentType: "application/json;charsr=utf-8",
dataType: "json",
success: function (data) {
var json = jQuery.parseJSON(data);
var value = "";
$(json.data).each(function () {
value += "【TestCaseId:" + this.TestCaseId
+ "; TestPlanId:" + this.TestPlanId
+ "; TestPlanName:" + this.TestPlanName
+ "; Description:" + this.Description
+ "; AssignedTo:" + this.AssignedTo
+ "; AreaPath:" + this.AreaPath
+ "; IterationPath:" + this.IterationPath
+ "; State:" + this.State
+ "; Reason:" + this.Reason
+ "; TestEnvironment:" + this.TestEnvironment
+ "; AutomatedTestStorage:" + this.AutomatedTestStorage
+ "; AutomatedTestType:" + this.AutomatedTestType
+ "; Tested:" + this.Tested
+ "; Attachments:" + this.Attachments
+ "; AllLinks:" + this.AllLinks
+ "】<br/>";
});
$("#valuesshow").html(value);
}
});
}
</script>
</head>
<body>
<div style="width:200px; margin:200px auto;">
<input id="BtnExport" type="button" value="查询测试计划 " class="btn btn-default btn-sm btn_style" /><br /><br />
<input id="BtnCaseSuit" type="button" value="查询测试套件" class="btn btn-default btn-sm btn_style" /><br /><br />
<input id="BtnCaseSearch" type="button" value="查询执行用例" class="btn btn-default btn-sm btn_style" /><br /><br />
<input id="BtnWorkItemDetails" type="button" value="查询工作项详情 " class="btn btn-default btn-sm btn_style" /><br />
<input id="BtnUpdateTestCaseResult" type="button" value="更新测试用例执行结果 " class="btn btn-default btn-sm btn_style" /><br /><br />
<input id="BtnGetDetailsOfTestCase" type="button" value="查询测试用例详情 " class="btn btn-default btn-sm btn_style" />
</div>
<div id="valuesshow"></div>
</body>
</html>