Open.CoreMDB Part 2 – Refactoring
You’ll find an embedded player for the recording at the top of this post. This video is just over 90 minutes long, but it forms the ground work for what will become a full test drive developed piece of open source software that I’m calling Open.CoreMDB.
Recording Date
I originally recorded this on the July 15th, 2018.
The Purpose
The idea with part two in this series was to begin a full system refactor. In the first part, we’d built the entire system in one project
the src
project
and leaving it like that would be a nightmare. So, the entire system was broken up into several parts:
- Open.CoreMDB.Api
- Open.CoreMDB.Data
- Open.CoreMDB.Services
- Open.CoreMDB.Shared
This way, we can work on individual parts of the system and keep them separated and loosely coupled.
leaving the entire source in one project would mean that the system was tightly coupled
We also started adding an API to the project. This took the form of an ASP.NET Core WebApi project, and has a single controller (ResourceController
) with a single method (Get
).
We also used VS Code’s built in task runner to build a task which would continuously run our unit tests
this gives us Live Unit Testing-like abilities
Essentially, whenever a change is made to anywhere in the code base, the unit tests are re-run and we see the immediate result of our code change.
The following is the task that we created:
{ | |
"label": "test with coverage (continuous)", | |
"command": "dotnet", | |
"type": "process", | |
"args":[ | |
"watch", | |
"--project", | |
"${workspaceFolder}/tests", | |
"test", | |
"/p:CollectCoverage=true", | |
"/p:CoverletOutputFormat=lcov", | |
"/p:CoverletOutput=./lcov.info", | |
"${workspaceFolder}/tests/Open.CoreMDB.Tests.csproj" | |
] | |
} |
This task was based on some of the points raised in this blog post, by Scott Hanselman.
Issues in the Stream
From around the 1 hour mark onward, I started having trouble with xunit’s global CLI tool
i.e. the dotnet xunit
command
After the stream, I found that the reason for this was because the xunit global CLI tooling has been deprecated and doesn’t support ASP.NET Core MVC. As such, what I should have done was continue to run my task for continuously running the unit tests.
Show Notes
I mentioned the following resources in this stream:
which includes a code of conduct for folks who wish to contribute
- Live Unit Testing in Visual Studio
- Automatic Unit Testing in .NET Core plus Code Coverage in Visual Studio Code
- Practical Test-Driven Development by John Calloway and Clayton Hunt