Announcing Cake.Newman

I've just published another new addin for Cake: Cake.Newman.

This addin integrates with the Newman CLI by Postman Labs, which can be used to run tests aginst Postman API Collections. Use this addin in your build scripts to easily test not just your API code, but also to run actual integration tests against your API.

I'll be publishing a more detailed post on using Postman Collections to test your API including writing simple tests soon.

This addin supports (almost) all of the options and inputs the full Newman CLI does, using a simple and flexible fluent API. This means your script can be as simple as RunCollection("./collection.json"); or as complicated as:

RunCollection("./collection.json", s => 
    s.DisableStrictSSL()
    .ExitOnFirstFailure()
    .IgnoreRedirects()
    .RunOnlyFolder("Tests")
    .SetRequestDelay(1000)
    .SetRequestTimeout(5000)
    .ExportCollectionTo("./export-collection.json")
    .ExportGlobalsTo("./export-globals.json")
    .ExportEnvironmentTo("./export-environments.json")
    .UseCLIReporter(c => 
        c.RunSilently()
        .DisableAssertions()
        .DisableConsoleOutput()
        .DisableSeparateFailures()
        .DisableSummary())
    .UseHtmlReporter(h =>
        h.UseOutputFile("./output-report.html")
        .UseTemplateFile("./template.html"))
    .UseJsonReporter("./output-report.json")
    .UseJUnitReporter("./output-report.xml"));

depending on how many of Newman's dizzying array of options you want to use in your script.

Installing and using

Using the addin is simple: just include #addin nuget:?package=Cake.Newman at the top of your Cake script, then call the RunCollection alias, optionally with settings.

However, the addin doesn't include Newman itself, which is installed through npm. If you don't have it installed on your infrastructure, you can use philo's excellent cake-npm addin to install Newman as part of your script:

#addin "Cake.Npm"
// in a Task/Setup block
Npm.Install(settings => settings.Package("newman").Globally());

Finally, you can check the documentation on GitHub or on the Cake website (once it is updated). Newman's CLI documentation can also be found on the Postman GitHub repo.

Contributing

This addin has been published under the cake-contrib organisation for anyone to contribute to. We have a full suite of unit tests and coverage tests, and I always accept bugs, feedback, feature requests and PRs on GitHub.

Build and Release status

Status master develop
Build
Release