Testing Archives - Code Maze https://code-maze.com/category/testing/ Learn. Code. Succeed. Mon, 13 Jan 2025 07:47:49 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.5 https://code-maze.com/wp-content/uploads/2020/01/Code-Maze-Favicon.png Testing Archives - Code Maze https://code-maze.com/category/testing/ 32 32 How to Perform Snapshot Testing With Verify in C# https://code-maze.com/csharp-snapshot-testing-with-verify/ https://code-maze.com/csharp-snapshot-testing-with-verify/#respond Mon, 13 Jan 2025 07:47:49 +0000 https://code-maze.com/?p=123741 In this article, we are going to discuss how to perform snapshot testing on objects using the Verify library. Testing is an important part of our software development pipeline. As developers, we often rely on familiar testing approaches like unit testing, where we assert the behavior of individual components of an application, and integration testing, […]

The post How to Perform Snapshot Testing With Verify in C# appeared first on Code Maze.

]]>
https://code-maze.com/csharp-snapshot-testing-with-verify/feed/ 0
Load Testing ASP.NET Core Web API With JMeter https://code-maze.com/aspnetcore-load-testing-web-api-with-jmeter/ https://code-maze.com/aspnetcore-load-testing-web-api-with-jmeter/#respond Thu, 05 Sep 2024 05:45:32 +0000 https://code-maze.com/?p=120961 In this article, we will learn how to load test an ASP.NET Core Web API with JMeter. So let’s get going. Introduction to JMeter Load testing is crucial for ensuring that web applications perform well under heavy traffic. JMeter is a popular and robust open-source tool for measuring the performance and functionality of web applications. When […]

The post Load Testing ASP.NET Core Web API With JMeter appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-load-testing-web-api-with-jmeter/feed/ 0
How to Test IServiceCollection Registrations in .NET https://code-maze.com/dotnet-how-to-test-iservicecollection-registrations/ https://code-maze.com/dotnet-how-to-test-iservicecollection-registrations/#respond Fri, 19 Jul 2024 06:10:00 +0000 https://code-maze.com/?p=120462 Unit testing IServiceCollection registrations in .NET enables us to test our application’s IServiceCollection to confirm that the setup of dependency injection is correct, allowing us to catch errors early in development. E.g. if we fail to register a service or register a service incorrectly with the wrong lifetime, we would be able to detect such […]

The post How to Test IServiceCollection Registrations in .NET appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-how-to-test-iservicecollection-registrations/feed/ 0
How to Use FakeLogger to Test Logging Code in .NET https://code-maze.com/dotnet-how-to-use-fakelogger/ https://code-maze.com/dotnet-how-to-use-fakelogger/#respond Wed, 19 Jun 2024 06:21:44 +0000 https://code-maze.com/?p=117077 In software development, logging, and unit testing serve as foundational tools, each actively contributing to the reliability and functionality of our applications. While unit testing promptly alerts us to changes in our application’s business logic, logging actively monitors errors, performance metrics, and runtime execution flow. Despite their significance, many development workflows often overlook their incorporation. […]

The post How to Use FakeLogger to Test Logging Code in .NET appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-how-to-use-fakelogger/feed/ 0
How to Mock IConfiguration.GetValue in ASP.NET Core https://code-maze.com/aspnetcore-mock-iconfiguration-getvalue/ https://code-maze.com/aspnetcore-mock-iconfiguration-getvalue/#comments Tue, 04 Jun 2024 05:26:57 +0000 https://code-maze.com/?p=116947 In this article, we’ll take a closer look at how we can mock IConfiguration.GetValue when writing unit tests in ASP.NET Core. Let’s start! Mock IConfiguration.GetValue in ASP.NET Core Before we start mocking, we need a class that utilizes IConfiguration: public class FinanceService(IConfiguration configuration) : IFinanceService { public double CalculateTotalAmount(double hours) { var hourlyRate = configuration.GetValue<double>("FinanceSettings:HourlyRate"); […]

The post How to Mock IConfiguration.GetValue in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-mock-iconfiguration-getvalue/feed/ 2
How to Test gRPC Services in ASP.NET Core https://code-maze.com/aspnetcore-test-grpc-services/ https://code-maze.com/aspnetcore-test-grpc-services/#respond Fri, 12 Apr 2024 05:29:48 +0000 https://drafts.code-maze.com/?p=114177 gRPC is a popular way to create fast and scalable API’s in the .NET world. In this article, we explore how to test gRPC Services in .NET applications, and set up both unit and integration tests to ensure the reliability and performance of gRPC services. So let’s start. What is gRPC? In general, gRPC is […]

The post How to Test gRPC Services in ASP.NET Core appeared first on Code Maze.

]]>
https://code-maze.com/aspnetcore-test-grpc-services/feed/ 0
Architecture Tests in .NET with NetArchTest.Rules https://code-maze.com/csharp-architecture-tests-with-netarchtest-rules/ https://code-maze.com/csharp-architecture-tests-with-netarchtest-rules/#respond Thu, 07 Mar 2024 06:58:00 +0000 https://code-maze.com/?p=109747 In this article, we’ll explore how to use the NetArchTest.Rules library to write architecture tests for our .NET applications. Let’s dive in! Creating the Base for Architecture Tests in .NET For this article, we’re going to use a simple project based on the Onion architecture: We create several projects representing the different layers of this […]

The post Architecture Tests in .NET with NetArchTest.Rules appeared first on Code Maze.

]]>
https://code-maze.com/csharp-architecture-tests-with-netarchtest-rules/feed/ 0
How to Overwrite DateTime.Now During Testing in .NET https://code-maze.com/dotnet-how-to-overwrite-datetime-now-during-testing/ https://code-maze.com/dotnet-how-to-overwrite-datetime-now-during-testing/#respond Tue, 13 Feb 2024 11:09:13 +0000 https://code-maze.com/?p=109029 In this article, we’ll look closer at how we can overwrite the DateTime.Now property when testing applications in .NET. Let’s dive in! Setup to Overwrite DateTime.Now During Testing in .NET Before we can start testing, we need to create our code base: public class Flight { public required string From { get; set; } public […]

The post How to Overwrite DateTime.Now During Testing in .NET appeared first on Code Maze.

]]>
https://code-maze.com/dotnet-how-to-overwrite-datetime-now-during-testing/feed/ 0
How to Pass Complex Parameters to Theory in xUnit https://code-maze.com/xunit-how-to-pass-complex-parameters-to-theory/ https://code-maze.com/xunit-how-to-pass-complex-parameters-to-theory/#comments Tue, 06 Feb 2024 23:07:02 +0000 https://code-maze.com/?p=107728 In this article, we are going to explore different ways to pass complex parameters to Theory test methods in xUnit. Let’s start testing! Setup to Pass Complex Parameters in xUnit For this article, we’ll use a simple library system: public class Book { public required int Id { get; set; } public required string Title […]

The post How to Pass Complex Parameters to Theory in xUnit appeared first on Code Maze.

]]>
https://code-maze.com/xunit-how-to-pass-complex-parameters-to-theory/feed/ 1
Differences Between NUnit, xUnit and MSTest https://code-maze.com/csharp-testing-framework-differences-between-nunit-xunit-and-mstest/ https://code-maze.com/csharp-testing-framework-differences-between-nunit-xunit-and-mstest/#respond Wed, 03 Jan 2024 12:13:43 +0000 https://code-maze.com/?p=103833 A testing framework provides us with an approach to automating the validation of the functionality and performance of our code. In this article, we will look at the three major testing frameworks (NUnit, xUnit, and MSTest) that are available for a .NET project.  However, before we dive in, let’s understand why we need a testing […]

The post Differences Between NUnit, xUnit and MSTest appeared first on Code Maze.

]]>
https://code-maze.com/csharp-testing-framework-differences-between-nunit-xunit-and-mstest/feed/ 0