A .NET Core console application with unit tests.
MyApp/
├── src/
│ └── MyApp/ # Main application
├── tests/
│ └── MyApp.Tests/ # Unit tests
└── MyApp.sln # Solution file
- .NET 8.0 SDK or later
- Create the project directory:
mkdir MyApp
cd MyApp- Create a solution:
dotnet new sln -n MyApp- Create the console app project inside
src:
dotnet new console -o src/MyApp- Create a test project inside
tests:
dotnet new xunit -o tests/MyApp.Tests- Add both projects to the solution:
dotnet sln add src/MyApp/MyApp.csproj
dotnet sln add tests/MyApp.Tests/MyApp.Tests.csproj- Add a reference from the test project to the main app:
dotnet add tests/MyApp.Tests/MyApp.Tests.csproj reference src/MyApp/MyApp.csproj- Run the tests:
dotnet testgit clone <repository-url>
cd MyApp
dotnet restoredotnet builddotnet testdotnet run --project src/MyApp/MyApp.csprojThis project uses:
- .NET 8.0 - Target framework
- xUnit - Testing framework
MIT