{"id":5351,"date":"2023-01-20T09:25:34","date_gmt":"2023-01-20T08:25:34","guid":{"rendered":"https:\/\/blog.besharp.it\/?p=5351"},"modified":"2023-01-20T14:12:19","modified_gmt":"2023-01-20T13:12:19","slug":"easy-integration-testing-using-postman-and-newman","status":"publish","type":"post","link":"https:\/\/blog.besharp.it\/easy-integration-testing-using-postman-and-newman\/","title":{"rendered":"Easy Integration testing using Postman and Newman"},"content":{"rendered":"\n

Introduction<\/h2>\n\n\n\n

Welcome back to the Proud2beCloud<\/strong> blog. Today we\u2019ll be exploring how to implement integration testing for your API directly into your pipelines by leveraging Postman and Newman.<\/p>\n\n\n\n

We\u2019ll talk about Newman, Pipelines and CodeBuild, Testing, scripting, sharability, and much more.<\/p>\n\n\n\n

Let’s dive into how to test APIs automatically and… start testing today!<\/p>\n\n\n\n

Why should I need to do integration testing?<\/h2>\n\n\n\n

To be able to safely deploy APIs in production we want to be sure that the expected behavior is going to be followed. With unit testing alone, we cannot be sure of that.<\/strong> <\/p>\n\n\n\n

Let’s put a simple example: imagine having an application unit tested perfectly, hence the code is working as expected given a known input. In front of the application, we\u2019ll then have a user calling an API and passing some data to the app. Unit tests are simply not enough; we want to be able to test the effective format of variables passed to the application logic, test headers, and body prior to utilization, timeouts, different status code, and other test cases: write tests for integration.<\/p>\n\n\n\n

In real-world applications, behaviors change over time, and modules connected to each other may face changes in how the data is passed onto the other and in API requests.<\/p>\n\n\n\n

We may have some third-party applications integrated into our solution where we need to call external API and test using their responses.<\/p>\n\n\n\n

Sometimes (but it should not happen!<\/em>) developers deploy applications quickly, maybe without unit testing and that\u2019s where integration testing comes in clutch.<\/p>\n\n\n\n

Those are some reasons why we need this integration testing: to test how various modules (route, validation, application, data layer) interact with each other, after changes and overtime.<\/strong><\/p>\n\n\n\n

In our case, talking about API Gateway and Lambda, we also want to test the route, decorators, and whatever is in between the user and the application code. <\/p>\n\n\n\n

Let\u2019s have a quick look at Postman<\/h2>\n\n\n\n

Best practices:<\/p>\n\n\n\n