2014-11-21 81 views
0

我试图在量角器中运行一些简单的测试,并尝试生成相同的XML报告。报告生成量角器不一致

My conf file : 

    // An example configuration file. 
    exports.config = { 
     directConnect: true, 

     // Capabilities to be passed to the webdriver instance. 
     capabilities: { 
     'browserName': 'chrome' 
     }, 
    //multiCapabilities: [{ 
    // browserName: 'firefox' 
    // }, { 
     // browserName: 'chrome' 
     //}], 
     // Spec patterns are relative to the current working directly when 
     // protractor is called. 
     specs: ['DriverScript.js'], 

     onPrepare: function() { 
    // The require statement must be down here, since jasmine-reporters 
    // needs jasmine to be in the global and protractor does not guarantee 
    // this until inside the onPrepare function. 
    browser.manage().timeouts().pageLoadTimeout(40000); 
    browser.manage().timeouts().implicitlyWait(20000); 
    require('jasmine-reporters'); 
    jasmine.getEnv().addReporter(
    new jasmine.JUnitXmlReporter('xmloutput', true, true)); 
    }, 

     // Options to be passed to Jasmine-node. 
     jasmineNodeOpts: { 
     showColors: true, 
     defaultTimeoutInterval: 10000000 
     } 
    }; 

规格文件:

Spec file : DriverScript 

var util = require('util'); 

describe('Bugzilla', function() { 

    beforeEach(function() { 
    browser.ignoreSynchronization = true; 
     browser.get('https://landfill.bugzilla.org/bugzilla-4.4-branch/index.cgi/bugzilla/'); 
    }); 

    var login = require('../Bugzilla/Login-pom.js'); 
    it('Login page should be open', function() { 

     login.click_login(); 
     browser.driver.sleep(10000); 
     login.userName(); 
     login.password(); 
     login.submit(); 
    }); 

     var bug = require('../Bugzilla/FileBug-pom.js'); 
    it('File a Bug page should be open', function() { 
     bug.click_fileBug(); 
     browser.driver.sleep(10000); 
     bug.widget(); 
     browser.driver.sleep(10000); 
     bug.severity(); 
     bug.hardware(); 
     bug.os(); 
     bug.description(); 

    }); 


}); 

describe('Bugzilla', function() { 



    var search = require('../Bugzilla/search-pom.js'); 
    it('Search page should be open', function() { 

     search.click_home(); 
     browser.driver.sleep(10000); 
     search.click_search(); 
     browser.driver.sleep(10000); 
     search.status(); 
     search.product(); 
     search.words(); 
     search.submit(); 
     browser.driver.sleep(10000); 
    }); 

}); 

报告是如何产生只为最近执行的测试案例,或最近失败的测试用例。

我想要为所有测试用例生成报告。

回答

0

这不是一个错误,而是JUnitXmlReporter的工作方式。它会将每个describe保存在一个单独的文件中,使用前缀字符串“xmloutput”和描述名称作为文件名。但是,您的两个描述都被命名为“Bugzilla”,因此会覆盖另一个。将其中一个描述重新命名为其他内容(或将它们放在相同的描述中)可以解决您的问题。

尝试对像运行:

describe('working test', function(){ 

    it('should work 1', function() { 
    expect(true).toEqual(true); 
    }); 

    it('should work 2', function() { 
    expect(true).toEqual(true); 
    }); 
}); 

describe('broken test', function(){ 
    it('should fail 1', function() { 
    expect(true).toEqual(false); 
    }); 

    it('should fail 2', function() { 
    expect(true).toEqual(false); 
    }); 
}); 

会生成两个文件: “xmloutputTEST-brokentest.xml” 和 “xmloutputTEST-workingtest.xml”