Rally 拉力-数组不包含所有推送元素
我有一个应用程序,我正在尝试使用,但似乎在迭代数组并推进到另一个数组时,即将数组合并到一个数组中对我不起作用。示例-我看到所有213次推送到这个数组,但当我检查它的内容时,它们就更少了 下面是显示不完整数组推送列表的代码 对于213个测试用例,只有67个测试集被推送到阵列中Rally 拉力-数组不包含所有推送元素,rally,Rally,我有一个应用程序,我正在尝试使用,但似乎在迭代数组并推进到另一个数组时,即将数组合并到一个数组中对我不起作用。示例-我看到所有213次推送到这个数组,但当我检查它的内容时,它们就更少了 下面是显示不完整数组推送列表的代码 对于213个测试用例,只有67个测试集被推送到阵列中 that = this; that._testSetTestList = []; console.log('testsetdata',testsetdata);
that = this;
that._testSetTestList = [];
console.log('testsetdata',testsetdata);
Ext.Array.each(testsetdata, function(record) {
console.log('record.get(TestCases)',record.get('TestCases'));
Ext.Array.each(record.get('TestCases'), function(name, index) {
that._testSetTestList.push({
resID: name.FormattedID,
resName: name.Name,
resObject: name.ObjectID,
resSetID: record.get('FormattedID'),
resSet: record.get('Name'),
resSetObject: record.get('ObjectID'),
resSetProject: name.Project.ObjectID
});
console.log('_testSetTestList.push',{
resID: name.FormattedID
});
});
});
如果有什么问题,谁能告诉我我做错了什么。尝试使用以下代码:
this._testSetTestList = Ext.Array.flatten(Ext.Array.map(testsetdata, function(record) {
return Ext.Array.map(record.get('TestCases'), function(name, index) {
return {
resID: name.FormattedID,
resName: name.Name,
resObject: name.ObjectID,
resSetID: record.get('FormattedID'),
resSet: record.get('Name'),
resSetObject: record.get('ObjectID'),
resSetProject: name.Project.ObjectID
};
});
}))
基于使用来自的承诺的示例,下面是一个代码,它使用测试用例集合构建测试集网格,其中测试集数组
setsWithCases
的元素被推入另一个数组testsets
,第二个数组用于填充网格。第二个数组包含第一个数组的所有元素。我正在使用AppSDK2中包含的每个
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentsCls: 'app',
launch: function(){
var aStore = Ext.create('Rally.data.wsapi.Store', {
model: 'TestSet',
fetch: ['ObjectID', 'FormattedID', 'Name', 'TestCases'],
autoLoad: true,
context:{
projectScopeUp: false,
projectScopeDown: false
},
listeners:{
scope: this,
load: this._onStoreLoaded
}
});
},
_onStoreLoaded: function(store, records){
var setsWithCases = [];
var testsets = [];
var that = this;
var promises = [];
_.each(records, function(testset){
promises.push(that._getTestCases(testset, that));
});
Deft.Promise.all(promises).then({
success: function(results) {
_.each(results, function(result) {
if (result.TestCases.length > 0) {
setsWithCases.push(result);
}
});
_.each(setsWithCases, function(testset){
testsets.push(testset);
});
that._makeGrid(testsets);
}
});
},
_getTestCases:function(testset, scope){
var deferred = Ext.create('Deft.Deferred');
var that = scope;
var testcases = [];
var result = {};
var testsetRef = testset.get('_ref');
var testsetObjectID = testset.get('ObjectID');
var testsetFormattedID = testset.get('FormattedID');
var testsetName = testset.get('Name');
var testcaseCollection = testset.getCollection("TestCases", {fetch: ['Name', 'FormattedID']});
var testcaseCount = testcaseCollection.getCount();
testcaseCollection.load({
callback: function(records, operation, success){
_.each(records, function(testcase){
testcases.push(testcase);
});
result = {
"_ref": testsetRef,
"ObjectID": testsetObjectID,
"FormattedID": testsetFormattedID,
"Name": testsetName,
"TestCases": testcases
};
deferred.resolve(result);
}
});
return deferred;
},
_makeGrid:function(testsets){
var that = this;
var gridStore = Ext.create('Rally.data.custom.Store', {
data: testsets,
pageSize: 1000,
remoteSort: false
});
var aGrid = Ext.create('Rally.ui.grid.Grid', {
itemId: 'testsetGrid',
store: gridStore,
columnCfgs:[
{
text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
},
{
text: 'Name', dataIndex: 'Name', flex: 1
},
{
text: 'TestCases', dataIndex: 'TestCases', flex:1,
renderer: function(value) {
var html = [];
_.each(value, function(testcase){
html.push('<a href="' + Rally.nav.Manager.getDetailUrl(testcase) + '">' + testcase.get('FormattedID') + '</a>' + ' ' + testcase.get('Name'));
});
return html.join(', ');
}
}
]
});
that.add(aGrid);
}
});
Ext.define('CustomApp'{
扩展:“Rally.app.app”,
组件SCLS:“应用程序”,
启动:函数(){
var aStore=Ext.create('Rally.data.wsapi.Store'{
模型:“测试集”,
获取:['ObjectID','FormattedID','Name','TestCases'],
自动加载:对,
背景:{
projectScopeUp:错误,
projectScopeDown:错误
},
听众:{
范围:本,,
加载:此。已加载
}
});
},
_onStoreLoaded:功能(存储、记录){
var setsWithCases=[];
var testset=[];
var=这个;
var承诺=[];
_.每个(记录、功能(测试集){
承诺。推(那个._获取测试用例(测试集,那个));
});
灵巧。承诺。所有(承诺)。然后({
成功:功能(结果){
_.每个(结果、功能(结果){
如果(result.TestCases.length>0){
用cases.push设置(结果);
}
});
_.每个(设置带案例、功能(测试集){
push(testset);
});
即._makeGrid(测试集);
}
});
},
_getTestCases:函数(测试集,范围){
var deferred=Ext.create('Deft.deferred');
var=范围;
var testcases=[];
var result={};
var testsetRef=testset.get(“u ref”);
var testsetObjectID=testset.get('ObjectID');
var testsetFormattedID=testset.get('FormattedID');
var testsetName=testset.get('Name');
var testcaseCollection=testset.getCollection(“TestCases”,{fetch:['Name','FormattedID']});
var testcaseCount=testcaseCollection.getCount();
testcaseCollection.load({
回调:函数(记录、操作、成功){
_.每个(记录、功能(测试用例){
push(testcase);
});
结果={
“_ref”:testsetRef,
“ObjectID”:testsetObjectID,
“FormattedID”:testsetFormattedID,
“名称”:testsetName,
“测试用例”:测试用例
};
延迟。解决(结果);
}
});
延期归还;
},
_makeGrid:函数(测试集){
var=这个;
var gridStore=Ext.create('Rally.data.custom.Store'{
数据:测试集,
页面大小:1000,
remoteSort:false
});
var aGrid=Ext.create('Rally.ui.grid.grid'{
itemId:'testsetGrid',
商店:gridStore,
专栏CFGS:[
{
text:'Formatted ID',dataIndex:'FormattedID',xtype:'templatecolumn',
tpl:Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
},
{
文本:“名称”,数据索引:“名称”,flex:1
},
{
文本:“TestCases”,数据索引:“TestCases”,flex:1,
渲染器:函数(值){
var html=[];
_.each(值、函数(测试用例){
push(“”+“”+testcase.get('Name');
});
返回html.join(',');
}
}
]
});
添加(aGrid);
}
});
在我的案例中,问题不在于代码,而在于范围。我试图获取项目树中无法直接访问的测试用例的测试用例结果。我们在几个项目中都有测试用例,但是我们在不同项目的测试集中使用它们。如果我们查看此页面的项目可以直接访问作为查询测试集一部分的测试用例,则说明了测试用例结果,但如果测试用例位于从中查看应用程序的项目的兄弟项目中,则查询无法找到它们并获取它们的测试用例结果。解决方案是将所有测试用例合并到正确的项目下,以便应用程序可以从任何必需的项目访问它们。感谢您的建议,不幸的是,输出仍然是一样的。我进行了一步一步的调试,发现在迭代过程中,按下“that.\u testSetTestList”接收到了所有213个测试用例对象,但一旦它离开外部的“Ext.Array”。每个(迭代结束)数组突然有更少的元素,推送停止后,是否可能隐式应用某种类型的作用域或筛选器?