Skip to content

reportportal/agent-net-vstest

Repository files navigation

Build status

Installation

NuGet version

Install ReportPortal.VSTest.TestLogger NuGet package into your project with tests.

Configuration

Add new ReportPortal.json file into your project with Copy if newer value for Copy to Output Directory property.

Example of config file:

{
  "$schema": "https://raw.githubusercontent.com/reportportal/agent-net-vstest/master/src/ReportPortal.VSTest.TestLogger/ReportPortal.config.schema",
  "enabled": true,
  "server": {
    "url": "https://rp.epam.com",
    "project": "default_project",
    "apiKey": "7853c7a9-7f27-43ea-835a-cab01355fd17"
  },
  "launch": {
    "name": "VS Test Demo Launch",
    "description": "this is description",
    "debugMode": true,
    "attributes": [ "t1", "os:win10" ]
  }
}

More about configuration.

Tests execution

To execute tests with real-time reporting, specify Logger argument.

vstest.console.exe

vstest.console.exe MyTests.dll /TestAdapterPath:. /Logger:ReportPortal

dotnet test

dotnet test -l:ReportPortal
dotnet vstest MyTests.dll --logger:ReportPortal

Visual Studio Test Explorer

Add the *.runsettings file into solution with the following minimal content

<?xml version="1.0" encoding="UTF-8"?>
<RunSettings>
  <RunConfiguration>
    <TestAdaptersPaths>.</TestAdaptersPaths>
  </RunConfiguration>
  <LoggerRunSettings>
    <Loggers>
      <Logger friendlyName="ReportPortal">
        <Configuration>
          <Launch.Description>Ran from Visual Studio Test Explorer</Launch.Description>
        </Configuration>
      </Logger>
    </Loggers>
  </LoggerRunSettings>
</RunSettings>

In Test Explorer window select this file as run configuration (menu Test -> Test Settings -> Select Test Settings File).

Now you can execute tests in Visual Studio and see results on the server. Launch.Description property in xml is provided as an exmple how to put configuration properties for logger.

Parameters overriding

--logger:ReportPortal;Launch.Name="My new launch name"

Complex parameters such as Launch.Attributes can be overriden as k1:v1,k2:v2. , is reserved as a delimiter of launch attributes.

Environment variables

It's possible to override parameters via environment variables.

set reportportal_launch_name="My new launch name"
# execute tests

reportportal_ prefix is used for naming variables, and _ is used as delimeter. For example to override Server.Authentication.Uuid parameter, we need specify ReportPortal_Server_Authentication_Uuid in environment variables. To override launch tags we need specify ReportPortal_Launch_Attributes with tag1;os:win7 value (; used as separator for list of values).

Integrate logger framework

And how you can improve your logging experience with attachments or nested steps.

Useful extensions

  • SourceBack adds piece of test code where test was failed
  • Insider brings more reporting capabilities without coding like methods invocation as nested steps

License

ReportPortal is licensed under Apache 2.0

We use Google Analytics for sending anonymous usage information as library's name/version and the agent's name/version when starting launch. This information might help us to improve integration with ReportPortal. Used by the ReportPortal team only and not for sharing with 3rd parties. You are able to turn off it if needed.