通过SDK无法正确检索TestCases集合,但仅通过Web Service api检索

时间:2014-06-13 19:46:12

标签: rally testcase

从TestSet对象中检索TestCases集合的SDK无法正常工作IMO因为TestCase集合不是完整的对象数组,而TestCases集合的信息非常稀缺。 Web服务API正确返回它们,到目前为止只有2.0p5才能正确返回它们,而且2.0rc rc2和rc3都没有按预期返回它们

我做错了吗?

当我检索TestSet对象时,我只需要为每个测试用例获取带有所有完全限定对象的TestCases集合。

1 个答案:

答案 0 :(得分:1)

AppSDK rc2适用于WS API的v2.0。由于性能原因,v2.0删除了在同一响应中返回子集合的功能。 Per WS API documentation fetching a collection将返回一个带有count的对象和从中获取集合数据的url。要获得完整对象,需要单独的请求。在app example in this github repo中,当从组合框中选择测试集并加载testset时,TestCases集合会被处理:

 _onDataLoaded: function(store, records){
        if ((records.length === 0) && (this._grid)) {
            this._grid.destroy();
        }

        var that = this;

        var promises = [];
         _.each(records, function(tcr) {
            promises.push(that._getTestCase(tcr, that));
        });

        Deft.Promise.all(promises).then({
            success: function(results) {
                that._testcaseresults = results;
                that._createGrid(records);
            }
        });
    },
         _getTestCase: function(tcr, scope) {
            var deferred = Ext.create('Deft.Deferred');
            var that = scope;
            var testcaseOid = tcr.get('TestCase').ObjectID;
            Rally.data.ModelFactory.getModel({
            type: 'Test Case',
            scope: this,
            success: function(model, operation) {
                fetch: ['FormattedID','Name','Method'],
                model.load(testcaseOid, {
                    scope: this,
                    success: function(record, operation) {
                        var testName = record.get('Name');
                        var testFid = record.get('FormattedID');
                        var testMethod =  record.get('Method');
                        var tcrRef = tcr.get('_ref');
                        var tcrOid  = tcr.get('ObjectID');
                        var tcrVerdict  = tcr.get('Verdict');
                        var tcrBuild = tcr.get('Build');

                        result = {
                            "_ref"          : tcrRef,
                            "ObjectID"      : tcrOid,
                            "Verdict"       : tcrVerdict,
                            "Build"         : tcrBuild,
                            "TestCaseName"      : testName,
                            "TestCase"   : testFid,
                            "Method"    : testMethod   
                        };

                        deferred.resolve(result);    
                    }
                });
                }
            });
            return deferred; 
        }