如何添加测试用例到TFS通过REST

问题描述 投票:0回答:1

我执行LIB导出/同步测试用例到TFS automaticaly期间试运行。我的一个要求是,我需要使用的NodeJS对于这一点,所以我决定使用TFS REST API。在我的代码我使用“蔚DEVOPS节点-API” lib下,我可以连接并得到不同的元素,没有运气与添加测试用例。

我的网络是测试用例样的工作项目,因为我们应该补充上找到。不幸的是我没有找到一个方法来添加一个与Azure的DEVOPS节点的API。

我也试过送手动构造JSON,可惜的是没有运气找到到发送,因为我八方通得不到应有的网址:

Error: {"statusCode":404,"body":"Page not found."

我的要求范例:

 request.post({
            url: 'https://<url>/tfs/<default collection maybe?>/<project>/_apis/wit/workItems/test%20case',
            headers: {
                'Content-Type': 'application/json',
                'Authorization':'Basic ' + this.encodePat('<my auth token>')
            },
            rejectUnauthorized: false,//add when working with https sites
            requestCert: false,//add when working with https sites
            agent: false,//add when working with https sites
            json: rq
        },function (response, err, body){

            if (err) throw new Error(JSON.stringify(err));

            console.log('Body:',JSON.parse(body));
            console.log('Response:',response)
        });  

有谁知道wrom我在做什么,或者蔚DEVOPS节点-API能够添加工作项?

node.js rest tfs azure-devops-rest-api
1个回答
2
投票

如果你只想只需添加一个测试用例作为一个工作项目,你必须使用模板从这个链接Work Items - Create

POST https://dev.azure.com/ {组织} / {}项目/ _的API /机智/工作项/ $ {}类型?API版本= 5.0

你要添加到URL“?API版本= X.0”。这个例子:

https://<server name and port>/tfs/<collection name should be>/<project>/_apis/wit/workItems/$test%20case?api-version=3.0

你也有此模板编码您拍:

'Authorization':'Basic ' + this.encodePat(':<my auth token>')

在这里,你可以找到与node.js的构建任务的例子:https://github.com/ashamrai/AzureDevOpsExtensions/blob/master/CustomBuildTask/NewWICustomTask/index.ts

© www.soinside.com 2019 - 2024. All rights reserved.