* Document JustMock Console .NET tool

Co-authored-by: Ivo Stoilov <ivo_stoilov@hotmail.com>
This commit is contained in:
Tsvetko Hadjitsenev 2024-01-31 16:42:56 +02:00 коммит произвёл GitHub
Родитель f11ea661a3
Коммит 9b7e8acc1d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
8 изменённых файлов: 217 добавлений и 66 удалений

Просмотреть файл

@ -29,9 +29,12 @@ navigation:
integration:
title: Integrations
position: 7
integration/justmock-console:
title: JustMock Console
position: 2
integration/continuous-integration:
title: Continuous Integration
position: 3
position: 3
integration/continuous-integration/tfs-azure:
title: TFS and Azure Pipelines
position: 1
@ -40,9 +43,8 @@ navigation:
position: 4
knowledge-base:
title: Knowledge Base
position: 8
position: 8
## The application virtual path
baseurl: /devtools/justmock

Просмотреть файл

@ -16,7 +16,7 @@ This topic describes the approaches you can use to notify the CLR that there is
- Installation that adds a registry record for the profiler
- Setting environment variables to define the path to the profiler and enable it
>If you have already registered the profiler, [JustMock Console]({%slug justmock/integration/justmock-console%}) can help you setting the variables and enable the profiler automatically for you when using the installation-free integration.
>If you have already registered the profiler, [JustMock Console]({%slug justmock/integration/justmock-console/general%}) can help you setting the variables and enable the profiler automatically for you when using the installation-free integration.
## Installing JustMock
@ -110,7 +110,7 @@ Once you have the profiler set, you will need to enable that profiler before run
</tbody>
</table>
>[JustMock Console]({%slug justmock/integration/justmock-console%}) can help you setting the variables and do that automatically for you.
>[JustMock Console]({%slug justmock/integration/justmock-console/general%}) can help you setting the variables and do that automatically for you.
## Using the JustMock.Commercial NuGet Package

Двоичные данные
integration/images/JustMockConsoleHelp.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 15 KiB

Просмотреть файл

@ -1,60 +0,0 @@
---
title: JustMock Console
page_title: JustMock Console | JustMock Documentation
description: JustMock Console integration with Telerik JustMock
slug: justmock/integration/justmock-console
tags: justmock-console,console, command
published: True
position: 2
previous_url: /integration-justmock-console.html
---
# JustMock Console
The **JustMockConsole** comes in hady for executing **installation-free** elevated mocking tests extending the functionality of **JustMockRunner**. Those of you who are familiar using **JustMockRunner** will easily get used to **JustMockConsole**.
With **JustMockConsole** it is easy to execute **.NET Framework** and/or **.NET Core** tests. The tool is shipped with JustMock installation and can be located in the following folder:
```C:\Program Files (x86)\Progress\Telerik JustMock\Libraries```
To get a feeling about the functionality of the command line tool you may execute:
```Telerik.JustMock.Console --help```
A sample output from running the above command may look like following:
![Telerik.JustMock.Console Help](images/JustMockConsoleHelp.png)
Note that the command line options on the screenshot are part of **runadvanced** verb. The current version of **JustMockConsole** contains just a single verb that can be omitted, but we strongly advice to actually **include the verb** when using **JustMockConsole**. This way it will be far easier to adopt new versions of **JustMockConsole**, that may have more verbs and functionality.
## How to run profiler enabled JustMock tests in command prompt
Running advanced JustMock tests is achieved by specifying proper values for **—command** and **—command-args** options.
Below is example usage of JustMockConsole with VSTestConsole:
```Telerik.JustMock.Console runadvanced --command "vstest.console.exe" --command-args "C:\full\path\to\JustMock.Tests.dll"```
Another sample may use .NET Core **dotnet** tool like following:
```Telerik.JustMock.Console runadvanced --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""```
## How to run installation free profiling with JustMockConsole
In order to perform installation free profiling you need to provide values for **—profiler-path-32** and/or **—profiler-path-64** command line options depending on the profiled process. Here is an example for .Net Framework:
```Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --command "vstest.console.exe" --command-args "C:\full\path\to\JustMock.Tests.dll"```
And here is an example for .Net Core:
```Telerik.JustMock.Console runadvanced --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""```
Note that it is possible to mix 32 and 64 bit profiling by specifying both command options like:
```Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "vstest.console.exe" --command-args "C:\full\path\to\JustMock.Tests.dll"```
The same thing is applicable for .Net Core as well.
```Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""```

Просмотреть файл

@ -0,0 +1,82 @@
---
title: .NET Tool
page_title: .NET Tool | JustMock Documentation
description: Quick guide for installing and using Telerik JustMock Console as .NET tool
slug: justmock/integration/justmock-console/dotnet-tool
tags: justmock-console,dotnet,tool
published: True
position: 3
previous_url: /integration-justmock-console-dotnet-tool, /integration-justmock-console-dotnet-tool.html
---
# Description
JustMock Console is integrated with the [.NET Tools](https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools) infrastructure. The tool is packed as a NuGet package (Telerik.JustMock.Console.\<version\>.nupkg
), can be downloaded and installed on a client machine using the 'dotnet tool' command, and later can be invoked using the 'justmock-console' command.
We recommend using this flavor of JustMock Console when working with CI/CD since it provides a standardized way of provisioning and running tests that require JustMock's advanced features.
# Prerequisites
To use the tool you need to have the .NET SDK installed on your machine and [Telerik NuGet](https://nuget.telerik.com/v3/index.json) feed properly configured as a package source.
You can check the current NuGet sources with following command:
```bat
dotnet nuget list source
```
If the [Telerik NuGet](https://nuget.telerik.com/v3/index.json) feed is not present in the list you can add it using following command:
```bat
dotnet nuget add source "https://nuget.telerik.com/v3/index.json" --name "Telerik NuGet" --username "api-key" --password <TELERIK_NUGET_API_KEY>
```
Note: Check this [article](https://docs.telerik.com/kendo-ui/intro/installation/nuget-keys) to learn more about Telerik NuGet API keys.
# Installing JustMock Console
To install the JustMock Console tool, you can use the following command:
```bat
dotnet tool install --global Telerik.JustMock.Console [<version>]
```
The ***--global*** option specifies that the tool will be installed globally, meaning that it will be available for all users and projects on your machine. You can also install a tool locally for a specific project by using the ***--local*** option and specifying the project directory. Optionally, you can supply a ***\<version\>***, this way you can choose a specific version for installation instead of the latest one.
# Using JustMock Console
To use JustMock Console tool, you can simply invoke it by running 'dotnet justmock-console' from any command-line prompt.
Here is an example for Linux:
```bash
justmock-console runadvanced -p "/full/path/to/libTelerik.CodeWeaver.Profiler.so" -c "dotnet" -a "test \"/path/to/JustMock.Tests\""
```
This will provision JustMock by using the profiler located in "/full/path/to/libTelerik.CodeWeaver.Profiler.so", then will build and run all tests located in "/path/to/JustMock.Tests".
JustMock Console also provides a convenient way to enable integration with 3rd party profilers.
Here is an example how to run tests and collect coverage with [dotnet-coverage](https://learn.microsoft.com/en-us/dotnet/core/additional-tools/dotnet-coverage):
```bash
dotnet dotnet-coverage collect dotnet justmock-console runadvanced -p \"/full/path/to/libTelerik.CodeWeaver.Profiler.so\" -l -c \"dotnet\" -a \"test --nobuild\"
```
This will provision JustMock by using the profiler located in "/full/path/to/libTelerik.CodeWeaver.Profiler.so", will build, run and analize the code coverage for all tests located in "/path/to/JustMock.Tests".
## Command line options
The full list of JustMock Console command line options can be found <a href="/integration/justmock-console/general#command-line-options" target="_blank">here</a>.
# Uninstalling JustMock Console
To uninstall the tool, you can use the following command:
```bat
dotnet tool uninstall --global Telerik.JustMock.Console
```

Просмотреть файл

@ -0,0 +1,63 @@
---
title: General Information
page_title: General Information | JustMock Documentation
description: General Information about Telerik JustMock Console
slug: justmock/integration/justmock-console/general
tags: justmock-console,console,command
published: True
position: 1
previous_url: /integration-justmock-console-general, /integration-justmock-console-general.html
---
# JustMock Console
JustMock Console is a command line tool for running tests using JustMock's advanced features. It helps you run tests independently of the unit testing framework and integrate with other profilers loaded upon test execution.
Depending on the use case the tool can be distributed and used in two different ways:
* [Command Line Tool for Windows]({%slug justmock/integration/justmock-console/windows%}). A standalone console application that is built for Windows only. In this flavour the application needs to be manually distrubited and then invoked as a regular CLI application.
* [.NET Tool]({%slug justmock/integration/justmock-console/dotnet-tool%}). A cross-platform version of the tool that is integrated with the .NET tools infrastructure. In this flavor the tool can be distributed using **dotnet tool** command and can be invoked by using **justmock-console** command.
# Command Line options
The command line reference is common for Windows Command Line and .NET tools
JustMock Console command has the following format:
**Telerik.JustMock.Console | justmock-console [verb] \<options\>**
The current version of JustMock Console contains just a single verb (**runadvanced**) that can be omitted, but it is recommended to include the verb when using the tool. This way it will be easier to adopt new versions, that may have more verbs and functionality. Here are the command line options related to **runadvanced** verb:
| Command | Alias | Parameter | Required | Default | Description |
| :---: | :---: | :--- | :---: | :---: | :--- |
| --profiler-path-32 | | \<path\> | No | N/A | Setups the path to the JustMock profiler used for x86 architecture. |
| --profiler-path-64 | | \<path\> | No | N/A | Setups the path to the JustMock profiler used for x64 architecture. |
| --profiler-path | -p | \<path\> | No | N/A | Setups the path to the JustMock profiler used for default architecture. |
| --link-existing-profiler | -l | | No | false | Enables integration with 3-rd party profiler setup found in the current environment: **false** - disable the intergration; **true** - enable the integration. |
| --command | -c | \<path\> | Yes | N/A | Setups the path to the executable used for test runner. |
| --command-args | -a | \<command-arguments\> | Yes | N/A | Passes arguments to the test runner executable. The quotes used with arguments should be escaped. |
| --no-logo | | | No | false | Hides banner with logo and copyright notice: **false** - display the banner; **true** - hide the banner. |
| --help | | | No | N/A | Displays a help screen. |
| --version | | | No | N/A | Displays a version information. |
# Sample usage
Run the tests with the JustMock profier currently registered on the system using Command Line Tool for Windows:
```bat
Telerik.JustMock.Console runadvanced -c "dotnet" -a "test --no-build \"\full\path\to\JustMock.Tests\""
```
Run the tests with the JustMock profier existing in the specified path using .NET tool:
```bat
justmock-console runadvanced -p "\full\path\to\default\Telerik.CodeWeaver.Profiler.dll" -c "dotnet" -a "test --no-build \"\path\to\JustMock.Tests\""
```
Run the tests with the JustMock profier existing in the specified path and OpenCover integration using Command Line Tool for Windows::
```bat
OpenCover.Console -target:"Telerik.JustMock.Console" -targetargs:"runadvanced -p \"\full\path\to\default\Telerik.CodeWeaver.Profiler.dll\" -c vstest.console -a vstest \"\full\path\to\JustMock.Tests.dll\" -l" -output:opencovertests.xml
```

Просмотреть файл

@ -0,0 +1,64 @@
---
title: Windows Command Line Tool
page_title: Windows Command Line Tool | JustMock Documentation
description: Quick guide for installing and using Telerik JustMock Console as Windows Command Line tool
slug: justmock/integration/justmock-console/windows
tags: justmock-console,cmd,windows,commandline
published: True
position: 2
previous_url: /integration-justmock-console-windows, /integration-justmock-console-windows.html
---
# Installing and using JustMock Console Tool for Windows
Here are the main steps:
* Download and install Telerik JustMock from your Telerik account and follow the steps to install it on your machine. This will also install the JustMock Console tool.
* Locate the **Telerik.JustMock.Console.exe** file in the *Libraries* folder of the installation directory (by default *C:\Program Files (x86)\Progress\Telerik JustMock\Libraries*).
* Run inside your favorite command shell (CommandPrompt or Windows PowerShell) with the appropriate command line options to execute your tests. You can use the ***--help*** option to see the available options.
# Profiler enabled JustMock tests
Running advanced JustMock tests is achieved by specifying proper values for ***—command*** and ***—command-args*** options.
Below is example usage of JustMockConsole with VSTest Console:
```bat
Telerik.JustMock.Console runadvanced --command "vstest.console" --command-args "C:\full\path\to\JustMock.Tests.dll"
```
Another sample may use .NET CLI like following:
```bat
Telerik.JustMock.Console runadvanced --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""
```
# Installation free profiling
In order to perform installation free profiling you need to provide values for ***—profiler-path-32*** and/or ***—profiler-path-64*** command line options depending on the profiled process. Here is an example for .NET Framework:
```bat
Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --command "vstest.console" --command-args "C:\full\path\to\JustMock.Tests.dll"
```
And here is an example for .NET CLI:
```bat
Telerik.JustMock.Console runadvanced --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""
```
Note that it is possible to mix 32 and 64 bit profiling by specifying both command options like:
```bat
Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "vstest.console" --command-args "C:\full\path\to\JustMock.Tests.dll"
```
The same thing is applicable for .NET CLI as well.
```bat
Telerik.JustMock.Console runadvanced --profiler-path-32 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\32\Telerik.CodeWeaver.Profiler.dll" --profiler-path-64 "C:\Program Files (x86)\Progress\Telerik JustMock\Libraries\CodeWeaver\64\Telerik.CodeWeaver.Profiler.dll" --command "dotnet" --command-args "vstest \"C:\full\path\to\JustMock.Tests.dll\""
```
# Command line options
The full list of JustMock Console command line options can be found <a href="/integration/justmock-console/general#command-line-options" target="_blank">here</a>.

Просмотреть файл

@ -23,7 +23,7 @@ To operate, JustMock needs to have specific variables registered in the environm
### With JustMock Console
The **JustMock Console** automatically prepares the environment so you can directly execute your tests and it is **the suggested approach** for running tests in console. For detailed instructions on how to use it, check the [JustMock Console]({%slug justmock/integration/justmock-console%}) topic.
The **JustMock Console** automatically prepares the environment so you can directly execute your tests and it is **the suggested approach** for running tests in console. For detailed instructions on how to use it, check the [JustMock Console]({%slug justmock/integration/justmock-console/general%}) topic.
### Manually