2016-09-21 27 views
0

我试图为我的量角器项目做詹金斯整合。我使用量角器,茉莉花来写测试。我使用nodeJs在Visual Studio中配置项目。詹金斯整合到量角器项目

我可以手动运行所有测试。现在,我打算尝试Jenkins集成,以便我的项目可以连续运行。

请给我建议的方式或任何有用的媒体。 我的'RunConf.js'文件如下。我使用这个文件来运行这两个套件。

var Jasmine2HtmlReporter = require('protractor-jasmine2-html-reporter'); 

exports.config = { 
framework: 'jasmine2', 
seleniumAddress: 'http://localhost:4444/wd/hub', 
capabilities: 
{ 
    'browserName': 'chrome', 
    'shardTestFiles': true, 
    'maxInstances': 2, 
    chromeOptions: { 
     args: ['chrome.switches', '--disable-extensions'] 
    } 
}, 
suites: { 
    loginpage: 'login.js', 
    addproduct: 'addproduct.js' 
}, 
//specs: ['addproduct.js'], 
jasmineNodeOpts: { 
    onComplete: null, 
    isVerbose: false, 
    includeStackTrace: true, 
    showColors: true, 
    defaultTimeoutInterval: 30000 
}, 

onPrepare: function() { 
    browser.driver.ignoreSynchronization = true; 
    return new Promise(function(fulfill, reject) { 
     browser.getCapabilities().then(function(value) { 
      reportName = value.get(Math.random(8,2)) + '_' + value.get('browserName') + '_' + Math.floor(Math.random() * 1E16); 
      jasmine.getEnv().addReporter(
       new Jasmine2HtmlReporter({ 
        //cleanDestination: false, 
        savePath: 'target/', 
        docTitle: 'Web UI Test Report', 
        screenshotsFolder: 'image', 
        //takeScreenshots: true, 
        takeScreenshotsOnlyOnFailures: true, 
        consolidate: true, 
        consolidateAll: true, 
        // preserveDirectory: true, 
        //fixedScreenshotName: true, 
        filePrefix: reportName + ".html" 
       }) 
      ); 
      fulfill(); 
     }); 
    }); 
}, 
afterLaunch: function afterLaunch() { 
    var fs = require('fs'); 
    var output = ''; 
    fs.readdirSync('target/').forEach(function(file) { 
     if (!(fs.lstatSync('target/' + file).isDirectory())) 
      output = output + fs.readFileSync('target/' + file); 
    }); 
    fs.writeFileSync('target/ConsolidatedReport.html', output, 'utf8'); 
} 

}

+0

如果您自己尝试设置,并且在此处详细发布任何*特定*问题/问题,则您更有可能得到回复。你的问题涵盖了一些可能在某些地方非常主观的主题,并且一般来说范围很大/很广泛,使得几乎不可能回答。 – Gunderson

回答

0

詹金斯可以运行您的构建工作。但首先你需要创建一个可以运行脚本的构建作业。要做到这一点:

  1. 确保您的程序可用于从您的VCS(即您的git存储库)jenkins。
  2. 创建构建工作,将检查出你的项目
  3. 在这个构建工作,创建一个脚本,可以从命令行调用你的量角器测试。

没有你的任何更多的信息,这是我可以建议的最好的。

+0

感谢您的回复。 –

+0

我创建了一个批处理文件来运行我的量角器测试,它工作正常。我试着在Jenkins Job中添加构建步骤作为'Execute Shell'并将代码设置为'start cmd.exe/c cd'C:\ ProtractorDemo \ ProtractorDemo \ spec>“ 量角器RunConf.js --suite loginpage, addproduct'执行詹金斯的工作,什么都没有发生。 –