• Jeff Fillegar
  • Posts
  • How to Automate .NET APIs and MongoDb using Tosca

How to Automate .NET APIs and MongoDb using Tosca

Introduction

In this post, I’m going to show you how to automate API test cases that perform crud operations against a MongoDB collection of customer data.  Since I designed and developed the .NET API as a product, I certainly don’t want to write code to test it as well. Which brings me to one of my core quality engineering guidelines and that is to stop writing code to test code.    

Applications Under Test (AUT)

Before we get to building automated test cases, let’s take a look at the application or system under test and the data under test as well.  I am using a local MongoDB database, where I have created a Collection to store Customer Data.  At this time of this post, there was just over 100 customer records in the MongoDb Collection for us to work with

mongodb-customers-collection

MongoDb Customer Collection

This Customer record collection is the result of my ETL data pipeline that pulls data from my salesforce instance, onprem sql server, and SAP.  

Swagger file for .NET 6 API CRUD operations

mongodb-dotnet-api-crud-swagger

Which test cases will we automate with Tosca?

  • GetListofCustomers

  • GetCustomerByQuoteId

  • GetCustomerBySalesforceAccountId

  • CreateNewCustomer

Steps to Create Automated API Test Cases in Tosca

scan-swagger-file in tosca
tosca-api-request-response
tosca-api-mongodb-test-cases

Complete video demonstrating how to create API test cases

The video will demonstrate how to build an API automated test case against a .NET 6 API which retrieves customer data from a MongoDb collection. 

Tosca Subset Available for Download

Tosca subset can be found in my git repo here: