Skip to the content.

Unit tests

Unit tests are enabled for debug and watch docker-compose.yml files. For unit tests xUnit is used.

Local development:

Run watcher, runs source code on file change:

dotnet watch test

Run source code:

dotnet test

Docker development:

Run watcher, run source code on file change:

  1. Build and compose tests container
    docker-compose -f docker-compose.yml -f docker-compose.watch.yml up -d --force-recreate --build tests
    
  2. Get a bash shell in the container running container:
    docker-compose -f docker-compose.yml -f docker-compose.watch.yml exec tests /bin/bash
    
  3. Run watcher:
    dotnet watch test
    

Debug configuration:

  1. Build and compose tests container
    docker-compose -f docker-compose.yml -f docker-compose.debug.yml up -d --force-recreate --build tests
    
  2. Get a bash shell in the container running container:
    docker-compose -f docker-compose.yml -f docker-compose.debug.yml exec tests /bin/bash
    
  3. Run assembly:
    dotnet test
    

Filter tests:

Part:

dotnet test --filter "FullyQualifiedName~Tests.Tasks.Year2020.Day20.Part1"

Day:

dotnet test --filter "FullyQualifiedName~Tests.Tasks.Year2020.Day20"

Year:

dotnet test --filter "FullyQualifiedName~Tests.Tasks.Year2020"