2016-09-21 73 views
2

我使用量角器進行e2e測試。 我想到的是:我希望能夠使用一個配置文件運行不同的套件,並將報告存儲在不同的目錄中。當我運行從CMD量角器test.js --params.suite = Name1它將存儲報告在文件夾Name1,當我運行** - params.suite = Name2 *時,它會將報告存儲在Name2文件夾中。 我使用https://www.npmjs.com/package/jasmine2-protractor-utils#htmlreportdir量角器,有沒有辦法使用參數來配置報表目錄?

var configuration = new function() { 
this.reportPath = "C:/xxx/ProtractorTests/"; 
this.reportFileName = "reportName.html"; 
this.screenshotPath = "C:/xxx/Screenshots/"; }; 

exports.config = { 

... 

params: { 
    suite: "SuiteName" 
}, 

plugins: [ 
    { 
     path: 'node_modules/jasmine2-protractor-utils', 
     disableHTMLReport: false, 
     disableScreenshot: false, 
     screenshotPath: configuration.screenshotPath, 
     screenshotOnExpectFailure: true, 
     screenshotOnSpecFailure: true, 
     clearFoldersBeforeTest: true, 
     htmlReportDir: configuration.reportPath, 
     failTestOnErrorLog: { 
      failTestOnErrorLogLevel: 900 
     } 
    } 
], 

在以上代碼我從配置功能的路徑和使用它。我可以使用exports.config.params.suite變量來連接報告路徑字符串嗎?或者我做的全部錯誤,應該完全不同? 任何想法,將不勝感激。

回答

1

你可以使用yargs得到命令行參數:

configuration.screenshotPath += '/' + require('yargs').argv.suite 

只是npm install yargs --save得到yargs。

相關問題