Son olarak bahsedeceğimiz test proje şablonu mstest. Yine bu şablonu kullanarak da geliştirdiğimiz uygulamaları test edebileceğimiz unit testler yazabileceğimiz bir test projesi oluşturuyoruz.
İlk olarak --help opsiyonu komutumuzu inceleyelim.
dotnet new mstest --help
Komutu girdiğimizde karşımıza aşağıdaki gibi bir çıktı geliyor. Şimdi kullanacağımız opsiyonlara bakalım. Bunlar name ve output olacak.
--name opsiyonu ile uygulamaya verilecek ismi,
--output opsiyonu ile projenin oluşacağı dizinin yolunu belirleyebiliyoruz.
eg@debian:~$ dotnet new mstest --help
MSTest Test Project (C#)
Author: Microsoft
Description: A project that contains MSTest unit tests that can run on .NET on Windows, Linux and MacOS.
Usage:
dotnet new mstest [options] [template options]
Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.
Template options:
-f, --framework <net6.0|net7.0> The target framework for the project.
Type: choice
net7.0 Target net7.0
net6.0 Target net6.0
Default: net7.0
-p, --enable-pack Whether or not to enable packaging (via ("dotnet pack") for the project.
Type: bool
Default: false
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
To see help for other template languages (F#, VB), use --language option:
dotnet new mstest -h --language F#
dotnet new mstest --name <mstest_app_name> --output <output_directory>
Aşağıdaki çıktıdaki gibi komutu girdiğimizde ExampleSolution.MsTestApp1 adında /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.MsTestApp1 dizininde bir MSTest test projesi oluşmuş oluyor.
eg@debian:~$ dotnet new mstest --name ExampleSolution.MsTestApp1 --output /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.MsTestApp1
The template "MSTest Test Project" was created successfully.
Processing post-creation actions...
Restoring /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.MsTestApp1/ExampleSolution.MsTestApp1.csproj:
Determining projects to restore...
Restored /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.MsTestApp1/ExampleSolution.MsTestApp1.csproj (in 2.55 sec).
Restore succeeded.