This repository contains a sample project demonstrating Test-Driven Development (TDD)
using .Net 8 and Vertical Slice Architecture
based on Minimal APIs
in .NET Core. The project aims to showcase best practices for building maintainable and testable software.
Beside of creating some unit tests for achieving test driven development (TDD), we also covered integration and end-to-end testing here.
Feel free to explore the project, learn from the provided examples, and adapt the testing techniques to your own projects. If you have any questions or need further assistance, please don't hesitate to reach out. Happy testing!
Test driven development is a development process in which you write your unit tests before you write your implementation.
The process looks like this:
- Write a failing unit test. The test should be written in a way that describes what your code should be doing (Red Phase).
- Write just enough code to make the test pass. At this point it’s best not to worry about the quality of the code, just get a passing test (Green Phase).
- Refactor your code to improve readability and performance (Refactor Phase).
This is sometimes referred to as the Red/Green/Refactor
cycle
You then repeat this development cycle until the software is complete. One of the main reasons TDD is popular is because it removes the fear of change from projects, this is because the tests are always true and no matter what happens to your code, as long is the business logic is still sound.
- This application uses
Https
for hosting apis, to setup a valid certificate on your machine, you can create a Self-Signed Certificate, see more about enforce certificate here. - Install git - https://git-scm.com/downloads.
- Install .NET Core 8.0 - https://dotnet.microsoft.com/download/dotnet/8.0.
- Install Visual Studio, Rider or VSCode.
- Open tdd-sample.sln solution, make sure that's compiling.
- Navigate to
src/TDDSample.Api
and rundotnet run
to launch the api (ASP.NET Core Web API) - Open web browser https://localhost:5001/swagger Swagger UI
The application is in development status. You are feel free to submit pull request or create the issue.
The project is under MIT license.