使用sdk2,我想知道项目中有多少测试,以及这些测试中有多少是手动测试和自动测试。看起来我应该能够使用Collection Summaries来做到这一点。使用摘要的优点是,我可以获得一系列测试,而不是数百个测试列表,或进行多个查询(一个用于所有测试,一个用于手动测试)。
但该示例显示了如何查询用户故事中的缺陷摘要。它现在显示是否可以获得多选或其他类型字段的摘要。
我试着猜测下面的语法是什么,但它没有用:
Ext.create('Rally.data.wsapi.Store', {
model: 'TestCase',
fetch: ['Method:summary[Manual,Automated]'], // This is the key statement: how to fetch a summary?
pageSize: 1,
autoLoad: true,
listeners: {
load: function(store, records) {
var testcase = records[0];
var methodInfo = testase.get('Method');
var manualCount = methodInfo.Manual;
}
}
});
是否可以在查询中使用集合摘要只使用一个结果?
答案 0 :(得分:1)
这对于非集合属性(例如TestCase.Method)肯定有用。但是,WSAPI 2.0 Collection Summaries的开发是为了提供一种方便的方法来获取和汇总Artifacts的子集合的计数,而无需返回到WSAPI并查询集合本身。由于WSAPI 2.0因性能原因而无法自动保存子集合,因此摘要功能非常重要。
因此,摘要方法可用于汇总工件上的子集合对象的属性计数,例如:
https://rally1.rallydev.com/slm/webservice/v2.0/defect?fetch=Tasks:summary[State]&order=Rank
https://rally1.rallydev.com/slm/webservice/v2.0/hierarchicalrequirement?fetch=Defects:summary[Owner]&order=ScheduleState
要保存整个商店的加载只是为了获取属性计数,您可以通过TestCase方法在商店中设置过滤器,并使用单位页面大小来防止加载完整的记录集。然后使用getTotalCount()
汇总您想要的计数。
然而,由于必须加载WsapiStore并处理您希望汇总的每个属性的回调,这可能会有点麻烦。
通过使用Deft.js和Promises,它有点可口。这是一个使用promises和Deft.Deferred实现_getCount(modelType,attribute,attrValue)函数的基本示例:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
items: [
{
xtype: 'container',
itemId: 'gridContainer',
columnWidth: 1
}
],
_summaryGrid: null,
launch: function() {
this._summarizeTestCaseCounts();
},
_summarizeTestCaseCounts: function() {
var me = this;
var promises = [];
var resultArray = [];
promises.push(me._getCount('TestCase', 'Method', 'Manual'));
promises.push(me._getCount('TestCase', 'LastVerdict', 'Failed'));
promises.push(me._getCount('TestCase', 'LastVerdict', 'Pass'));
Deft.Promise.all(promises).then({
success: function(results) {
Ext.Array.each(results, function(result) {
resultArray.push(result);
console.log(result);
});
// Create grid from summarized results
me._makeGrid(resultArray);
}
});
},
_getCount: function(modelType, attribute, attrValue) {
var deferred = Ext.create('Deft.Deferred');
var artifactStore = Ext.create('Rally.data.wsapi.Store', {
model: modelType,
pagesize: 1,
autoLoad: true,
filters: [
{
property: attribute,
operator: '=',
value: attrValue
}
],
sorters: [
{
property: 'FormattedID',
direction: 'ASC'
}
],
listeners: {
load: function(store, records) {
var manualCount = store.getTotalCount();
result = {
"ModelType": modelType,
"Attribute": attribute,
"Value": attrValue,
"Count": manualCount
};
deferred.resolve(result);
}
}
});
return deferred;
},
_makeGrid: function(results) {
var me = this;
if (me._summaryGrid) {
me._summaryGrid.destroy();
}
var gridStore = Ext.create('Rally.data.custom.Store', {
data: results,
pageSize: 5,
remoteSort: false
});
me._summaryGrid = Ext.create('Rally.ui.grid.Grid', {
itemId: 'artifactGrid',
store: gridStore,
columnCfgs: [
{
text: 'Artifact', dataIndex: 'ModelType'
},
{
text: 'Attribute', dataIndex: 'Attribute'
},
{
text: 'Value', dataIndex: 'Value'
},
{
text: 'Count', dataIndex: 'Count'
}
]
});
me.down('#gridContainer').add(me._summaryGrid);
me._summaryGrid.reconfigure(gridStore);
}
});
顺便说一句,Matt Greer最近写了一篇fantastic blog posting,概述了他对使用Deft.js承诺的深刻印象。在构建Rally Apps时,了解如何使用它们对我非常有帮助。