- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试获取 Azure DevOps(以前的 VSTS)中的测试用例中定义的参数值。我的测试用例如下所示 - Azure devops test case
我正在尝试获取如下所示的测试方法中的值-
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.TestCase",
"https://[companyName].visualstudio.com;[projectName]",
"5843", // this is the test case number
DataAccessMethod.Sequential),
TestMethod]
public void DataOverlapsBottomRowOfFilterFromTestParameter()
{
string column1 = TestContext.DataRow[0].ToString(); // read parameter by column index
string column2 = TestContext.DataRow["Column2"].ToString(); //read parameter by column name
// rest of the code
}
运行此测试时,它甚至不会进入测试方法代码。它给出了这个错误 -
单元测试适配器无法连接到数据源或读取数据。有关解决此错误的详细信息,请参阅 MSDN 库中的“数据驱动单元测试故障排除”( http://go.microsoft.com/fwlink/?LinkId=62412 )。错误详细信息: 无法找到请求的 .Net Framework 数据提供程序。可能没有安装。
拜托,有人能指出我在这里缺少什么吗?我已遵循数据驱动单元测试文档。但我觉得我可能缺少一些可以让它发挥作用的东西。谢谢!
最佳答案
我正在回答我自己的问题。我通过使用 Microsoft.TeamFoundation.WorkItemTracking.WebApi、Microsoft.VisualStudio.Services.Common 和Microsoft.VisualStudio.Services.WebApi 命名空间。
代码是这样的
[TestMethod]
[WorkItem(1111)]
public void GetTestValuesFromTestParameter()
{
//This test is for continuous range
var method = MethodBase.GetCurrentMethod();
var attr = (WorkItemAttribute)method.GetCustomAttributes(typeof(WorkItemAttribute), true)[0];
var workItemId = attr.Id;
var dataTable = GetTableItemsFromTestCase(workItemId);
foreach (DataRow dataRow in dataTable.Rows)
{
//Rest of the code
}
}
GetTableItemsFromTestCase 方法 -
private DataTable GetTableItemsFromTestCase(int workItemId)
{
var accountUri = new Uri(""); // Account URL, for example: https://fabrikam.visualstudio.com
var personalAccessToken = "; // See https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/pats?view=vsts
// Create a connection to the account
var connection = new VssConnection(accountUri, new VssBasicCredential(string.Empty, personalAccessToken));
// Get an instance of the work item tracking client
var witClient = connection.GetClient<WorkItemTrackingHttpClient>();
IEnumerable<XElement> descendants = new List<XElement>();
var dt = new DataTable();
try
{
// Get the specified work item
var workitem = witClient.GetWorkItemAsync(workItemId).Result;
var itemParams = workitem.Fields["Microsoft.VSTS.TCM.Parameters"];
var itemParamsElement = XElement.Parse((string)itemParams);
var paramDataSource = workitem.Fields["Microsoft.VSTS.TCM.LocalDataSource"];
var xElement = XElement.Parse(paramDataSource.ToString());
//Assuming we have a table named "Table1" in the workitem
descendants = xElement.Descendants("Table1");
foreach (var xe in itemParamsElement.Descendants("param"))
{
var name = xe.Attribute("name").Value;
dt.Columns.Add(name, typeof(string));
}
foreach (var descendant in descendants)
{
var r = dt.NewRow();
foreach (var xe in descendant.Descendants())
{
r[xe.Name.LocalName] = xe.Value;
}
dt.Rows.Add(r);
}
}
catch (AggregateException aex)
{
VssServiceException vssex = aex.InnerException as VssServiceException;
if (vssex != null)
{
//log error
}
}
我希望它对其他人有帮助。从此链接获取身份验证帮助
https://learn.microsoft.com/en-us/azure/devops/integrate/get-started/authentication/pats?view=vsts
关于azure - 如何在 C# 测试中从 azure devops(以前的 vsts)上的测试用例获取参数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53560461/
SELECT ID, AppID, Description, Min([Transaction Date]) AS TransactionDate FROM AppProsHist WHERE [De
目前我正在创建规则,该规则应该检查方法是否包含 @Test 和 @TestInfo 注释。如果确实如此,@TestInfo 不应有空参数 testCaseId。 有几种不同的可能方法来填充 testC
是否可以设置参数值,使其在 where 子句中始终结果为 true? 作为示例,考虑一个查询: SELECT name FROM student WHERE class=@parameter; 现在我
我是 JPA 的新手,这是我的查询之一,我有几个参数作为查询的一部分,任何参数都可以为空值 @Query(value = "SELECT ord.purchaseOrderNumber,ord.sal
LOD 参数对 texturelod 取什么值? ?我发现的规范根本没有提到它。它是百分比还是带有百分比的索引值。如果是后者,有没有办法获得纹理具有的 mipmap 数量,以便我能够使用百分比? 最佳
我希望此代码替换现有的 URL 参数“aspid”,但它的作用是在现有的 id 上添加另一个 id。有人可以帮忙吗? $(document).ready(function() { function
在 Spring-boot 项目中,我尝试将 Date 对象作为请求参数传递,并收到此错误: Parameter value [1] did not match expected type [java
在我们的 Jenkinsfile 中,我们有很多参数(参数化构建),在这种情况下,我想检查每个参数是否已切换并对其进行操作。这些参数具有相似的名称,但以不同的小数结尾,因此我想迭代它们以实现此目的。
我的模板之一中有类似于以下内容的内容: 但是 Freemarker 不高兴并给了我: Exception in thread "main" freemarker.core.ParseExceptio
我正在从表单向重定向 servlet 发送一个 post 请求。然后,Servlet 将表单写入其响应 (getWriter) 对象。该表单包含许多隐藏字段。我使用 javascript 提交此表单(
我正在创建一个 JavaScript 组件,我正在根据 jQuery 结果创建该组件的实例,但是,我传递到构造函数中的 DOM 元素虽然在我单步执行调用代码中的循环时已填充,但在传递给构造函数时是未定
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我对 javascript 有疑问。 假设我有这样的 javascript 函数: function show_popup(id) { alert(id); } 编
我目前正在尝试抓取嵌入式 m3u8 url 路径以进行自学。 到目前为止,我设法确定请求会生成带有 m3u8 信息的 json 响应。 例如,https://headlines.yahoo.co.jp
谷歌地图 API 需要这样的参数: NSString *urlString=@"http://maps.google.com/maps?saddr=43.2923,5.45427&daddr=43.4
“parameterValue”是在 Javascript 中的事件上传递的默认参数吗?谁能解释一下这个值从何而来。 Load Ajax content 我发现它在以下文章中使用 - http://w
我有一个 .SWF 电子邮件提交表单。背景颜色通过以下方式设置: `` 并嵌入: `` 是否可以将鼠标悬停在对象或包含的 div 上来更改这些值?即#ffffff 非常感谢! 最佳答案 将 wmode
假设我想用指数函数拟合两个数组x_data_one和y_data_one。为此,我可以使用以下代码(其中 x_data_one 和 y_data_one 被赋予虚拟定义): import numpy
有什么方法可以填充 parameters在基于外部属性文件内容的 Liquibase 变更日志文件中? 例如,我希望能够说: 并将 table.name 的值和
我必须按原样发送参数值 'AbCd/EfgH'。但是 Angular 将 '/' 转义为 %2F。我无法控制 URL。 解决这个问题的最佳方法是什么? 我不想强制 Angular 停止对所有其他 UR
我是一名优秀的程序员,十分优秀!