如何将Postman集成测试与TeamCity集成

如何将Postman集成测试与TeamCity集成

问题描述:

我正在Postman中构建一套集成测试,以测试一些RESTful API。在TeamCity中构建项目时,我想运行这些测试。我正在考虑使用Newman命令行集成,但是找不到很好的例子。谁能建议实现这一目标的方法?

I'm building a suite of integration tests in Postman to test some RESTful APIs. I'd like to run these tests when building the project in TeamCity. I'm looking at perhaps using Newman command line integration, but I not finding good examples of this. Can anyone suggest an approach to make this happen?

我能够使用newman和grunt使其正常工作。我在exec下添加了newman,还在gruntfile中添加了grunt任务。这需要指向newman npm软件包的本地实例(不是全局实例)。

I was able to get this working using newman and grunt. I added newman under exec, and also added a grunt task in my gruntfile. This needed to point to the local instance of the newman npm package (not global).

'use strict';

module.exports = function (grunt) { // eslint-disable-line
    grunt.initConfig({
    ...
    exec: {         
        newman: {
            cmd: 'bin\\node.exe ./node_modules/newman/bin/newman run myProject.postman_collection.json'
        }
    },
    ...
});

grunt.registerTask('newman', ['exec:newman']);

我将TeamCity设置为作为一个构建步骤部署到测试环境,并添加了一个笨拙的构建步骤,该步骤称为我的任务。

I set TeamCity to deploy to a test environment as one build step and added a grunt build step that called my task.