I have a .NET Core application containing MSTest unit tests. What would the command be to execute all tests using this Dockerfile?
FROM microsoft/dotnet:1.1-runtime
ARG source
COPY . .
ENTRYPOINT ["dotnet", "test", "Unittests.csproj"]
Folder structure is:
/Dockerfile
/Unittests.csproj
/tests/*.cs
Use a base image with .NET Core SDK installed. For example:
microsoft/dotnet
microsoft/dotnet:1.1.2-sdk
Then run a dotnet test
console command. This is why SDK-based image is required - you cann't run dotnet test
in a Runtime-based image without SDK. Here is a fully-workable Dockerfile
example:
FROM microsoft/dotnet
WORKDIR /app
COPY . .
RUN dotnet restore
# run tests on docker build
RUN dotnet test
# run tests on docker run
ENTRYPOINT ["dotnet", "test"]
RUN
commands are executed during a docker image build process.
ENTRYPOINT
command is executed when a docker container starts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With