首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Rally中,当复制测试集时,如何将测试用例结果与测试集一起复制?

在Rally中,当复制测试集时,如何将测试用例结果与测试集一起复制?
EN

Stack Overflow用户
提问于 2014-02-25 02:11:24
回答 1查看 957关注 0票数 1

我是Rally的新手,到目前为止只使用过web界面(我还没有使用过编程语言中的Rally API)。有时,我们有一个测试集没有在迭代中完成,所以我们希望能够将测试集复制到下一个迭代中,但保留到目前为止在新迭代中输入的测试用例结果,这样我们就不必在两个不同的地方寻找完整的测试集结果。也许一种解决方案是更好的迭代计划,但我仍然很好奇,在复制测试集时,是否有一种方法可以复制测试用例结果和测试集。

EN

回答 1

Stack Overflow用户

发布于 2014-02-25 04:11:26

无法复制测试用例结果。可以使用相同的数据在UI或Web服务API中创建它,但它不支持复制功能。

有关如何使用浏览器REST客户端创建TCR对象的一般示例,请参阅此SO post here

这是一个概念应用程序,它创建了一个现有TCR的副本。该应用程序通过迭代过滤TestSets,并将这些TestSets加载到组合框中。基于combobox中的TestSet选择,将创建另一个用TestCases填充的组合框。当从该组合框中选择一个测试用例时,将使用TestCaseResults构建一个网格。双击网格中的TCR将调用复制功能。有关如何复制记录here的信息,请参阅AppSDK2主题。您可以根据您的规范扩展代码。源代码在this github repo中。

您至少需要在下面的_copyRecordOnDoubleClick方法中更改目标测试用例和目标测试集的ObjectID:

代码语言:javascript
复制
 Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'iteration',
    comboboxConfig: {
        fieldLabel: 'Select an Iteration:',
        labelWidth: 100,
        width: 300
    },


    onScopeChange: function() {
       if (this.down('#testSetComboxBox')) {
        this.down('#testSetComboxBox').destroy();
    }
    if (this.down('#testCaseComboxBox')) {
        this.down('#testCaseComboxBox').destroy();
    }
    if (this.down('#resultsGrid')) {
        this.down('#resultsGrid').destroy();
    }
    var testSetComboxBox = Ext.create('Rally.ui.combobox.ComboBox',{
        id: 'testSetComboxBox',
        storeConfig: {
        model: 'TestSet',
        pageSize: 100,
        autoLoad: true,
        filters: [this.getContext().getTimeboxScope().getQueryFilter()]
        },
        fieldLabel: 'select TestSet',
        listeners:{
                ready: function(combobox){
            if (combobox.getRecord()) {
            this._onTestSetSelected(combobox.getRecord());
            }
            else{
            console.log('selected iteration has no testsets');
            }
        },
                select: function(combobox){
            if (combobox.getRecord()) {
            this._onTestSetSelected(combobox.getRecord());
            }

                },
                scope: this
            }
    });
    this.add(testSetComboxBox);  
    },

     _onTestSetSelected:function(selectedTestset){
    var testCases = selectedTestset.getCollection('TestCases', {fetch: ['FormattedID','ObjectID', 'Results']});
    var ts  = {
            FormattedID: selectedTestset.get('FormattedID'),
            TestCaseCount: selectedTestset.get('TestCases').Count,
            TestCases: [],
            ResultCount: 0 
        };
    testCases.load({
        callback: function(records, operation, success){
            Ext.Array.each(records, function(testcase){
            console.log("testcase.get('FormattedID')", testcase.get('FormattedID'));  
            console.log("testcase.get('Results').Count", testcase.get('Results').Count); 
            ts.ResultCount = testcase.get('Results').Count; 
            ts.TestCases.push({_ref: testcase.get('_ref'),
                FormattedID: testcase.get('FormattedID'),
                ObjectID: testcase.get('ObjectID')
                });
          }, this); 
          this._makeTestCaseCombobox(ts.TestCases);
        },
        scope: this
      });

    },

    _makeTestCaseCombobox:function(testcases){
    if (this.down('#testCaseComboxBox')) {
        this.down('#testCaseComboxBox').destroy();
    }
    if (this.down('#resultsGrid')) {
        this.down('#resultsGrid').destroy();
    }
        if (testcases.length>0) {
        var idArray = [];
        _.each(testcases, function(testcase){
            console.log(testcase);
            console.log('OID', testcase['ObjectID']);
            idArray.push(testcase['ObjectID']);
            });
        console.log('idArray',idArray);

        var filterArray = [];
        _.each(idArray, function(id){
            filterArray.push(
            {
            property: 'ObjectID',
            value:id
            }
            )
        });
         var filters = Ext.create('Rally.data.QueryFilter', filterArray[0]);

         filterArray = _.rest(filterArray,1);  

         _.each(filterArray, function(filter){
            filters = filters.or(filter)
            },1);

         var testCaseComboxBox = Ext.create('Rally.ui.combobox.ComboBox',{
            id: 'testCaseComboxBox',
            storeConfig: {
            model: 'TestCase',
            pageSize: 100,
            autoLoad: true,
            filters:filters,
            fetch: true
            },
            fieldLabel: 'select TestCase',
            listeners:{
            ready: function(combobox){
                if (combobox.getRecord()) {
                this._onTestCaseSelected(combobox.getRecord());
                }
                else{
                console.log('selected testset has no testcases');
                }
            },
            select: function(combobox){
                if (combobox.getRecord()) {
                this._onTestCaseSelected(combobox.getRecord());
                }

            },
            scope: this
            }
        });
        this.add(testCaseComboxBox); 
        }
        else{
          console.log('selected testset has no testcases');
          }
    },

    _onTestCaseSelected:function(selectedTestcase){
      var results = selectedTestcase.getCollection('Results', {fetch: ['ObjectID','Date', 'TestSet', 'TestCase', 'Build', 'Verdict']});
      var tc  = {
            ObjectID: selectedTestcase.get('ObjectID'),
            FormattedID: selectedTestcase.get('FormattedID'),
            Results: [] 
        };
    results.load({
        callback: function(records, operation, success){
            Ext.Array.each(records, function(result){
            console.log("result.get('ObjectID')", result.get('ObjectID'));  
            console.log("result.get('Verdict')", result.get('Verdict'));
            tc.Results.push({_ref: result.get('_ref'),
                ObjectID: result.get('ObjectID'),
                Date: result.get('Date'),
                Build: result.get('Build'),
                Verdict: result.get('Verdict')
                });
          }, this); 
          this._updateGrid(tc.Results);
        },
        scope: this
      });
    },

    _updateGrid: function(results){
         var store = Ext.create('Rally.data.custom.Store', {
                data: results,
                pageSize: 100
            });
        if (!this.down('#resultsGrid')) {
        this._createGrid(store);
        }
        else{
        this.down('#resultsGrid').reconfigure(store);
        }
     },

  _createGrid: function(store){
        var that = this;
        var that = this;
        var resultsGrid = Ext.create('Rally.ui.grid.Grid', {
            id: 'resultsGrid',
            store: store,

            columnCfgs: [
            {
               text: 'ObjectID ID', dataIndex: 'ObjectID',
            },
            {
            text: 'Date', dataIndex: 'Date',
            },
            {
            text: 'Build', dataIndex: 'Build',
            },
            {
              text: 'Verdict', dataIndex: 'Verdict',
            },
            ],
             listeners: {
                celldblclick: function( grid, td, cellIndex, record, tr, rowIndex){
                that._copyRecordOnDoubleClick(record);     
                }
            }
        });
        this.add(resultsGrid);
     },

     _copyRecordOnDoubleClick: function(record){
      var that = this;
         console.log('record', record);
         Rally.data.ModelFactory.getModel({
                type: 'TestCaseResult',
                success: function(model) {  
                    that._model = model;
                    var copy = Ext.create(model, {
                        Date: record.get('Date'),
            Build: record.get('Build'),
            Verdict: record.get('Verdict'),
            TestCase: '/testcase/17237838118',
            TestSet: '/testset/17234968911'
                    });
                    copy.save({
                        callback: function(result, operation) {
                            if(operation.wasSuccessful()) {
                                console.log('result',result); 
                            }
                            else{
                                console.log("problem");
                            }
                        }
                    });
                }
            });
     }  
 });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21995639

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档