Skip to content

Latest commit

 

History

History
134 lines (87 loc) · 3.77 KB

RUNNING_TESTS.md

File metadata and controls

134 lines (87 loc) · 3.77 KB

Overview

The RabbitMQ .NET client's test suite assumes there's a RabbitMQ node listening on localhost:5672 (the default settings). TLS tests require a node listening on the default TLS port.

It is possible to use Visual Studio Community Edition and dotnet.exe in PATH, to build the client and run the test suite.

Building

Windows

build.ps1

MacOS and Linux

dotnet build ./Build.csproj

This will build all projects. After this open the solution in Visual Studio.

Test Environment Requirements

Tests can be run from Visual Studio using the XUnit Test Adapter. Note that it may take some time for the adapter to discover tests in the assemblies.

The test suite assumes there's a RabbitMQ node running locally with all defaults, and the tests will need to be able to run commands against the rabbitmqctl tool for that node. Two options to accomplish this are covered below.

Option One: Using a RabbitMQ Release

It is possible to install and run a node using any binary build suitable for the platform. Its CLI tools then must be added to PATH so that rabbitmqctl can be invoked directly without using an absolute file path. Note that this method does not work on Windows.

On Windows, you must run unit tests as follows (replace X.Y.Z with your RabbitMQ version):

$env:RABBITMQ_RABBITMQCTL_PATH='C:\Program Files\RabbitMQ Server\rabbitmq_server-X.Y.Z\sbin\rabbitmqctl.bat'
.\build.ps1 -RunTests

Option Two: Building a RabbitMQ Node from Source

T run a RabbitMQ node built from source:

git clone https://github.com/rabbitmq/rabbitmq-server.git rabbitmq-server
cd rabbitmq-server

# assumes Make is available
make co
cd deps/rabbit
make
make run-broker

rabbitmqctl location will be computed using a relative path under the source repository, in this example, it should be ./rabbitmq-server/deps/rabbit/sbin/rabbitmqctl.

It is possible to override the location using RABBITMQ_RABBITMQCTL_PATH:

RABBITMQ_RABBITMQCTL_PATH=/path/to/rabbitmqctl dotnet test projects/Test/Unit.csproj

Option Three: Using a Docker Container

It is also possible to run a RabbitMQ node in a Docker container. Set the environment variable RABBITMQ_RABBITMQCTL_PATH to DOCKER:<container_name> (for example DOCKER:rabbitmq-dotnet-client-rabbitmq). This tells the unit tests to run the rabbitmqctl commands through Docker, in the format docker exec rabbitmq01 rabbitmqctl <args>:

docker run -d --hostname rabbitmq01 --name rabbitmq01 -p 15672:15672 -p 5672:5672 rabbitmq:3-management

You should also be able to run the same script that sets up the Ubuntu 22 GitHub actions worker:

./.ci/ubuntu/gha-setup.sh

Running All Tests

Then, to run the tests use:

Windows

Note that the -RunTests does not run the OAuth2 test suite.

build.ps1 -RunTests

MacOS, Linux, BSD:

Note that the test target does not run the OAuth2 test suite.

make test

Running Individual Suites or Test Cases

Running individual tests and fixtures on Windows is trivial using the Visual Studio test runner. To run a specific tests fixture on MacOS or Linux, use the NUnit filter expressions to select the tests to be run:

dotnet test projects/Test/Unit.csproj --filter "Name~TestAmqpUriParseFail"

dotnet test projects/Test/Unit.csproj --filter "FullyQualifiedName~RabbitMQ.Client.Unit.TestHeartbeats"

Running Tests for a Specific .NET Target

To run tests targeting .NET 6.0:

dotnet test --framework net6.0 projects/Unit