VOOZH about

URL: https://deepwiki.com/Accenture/Ocaramba/3.3-test-runner-integrations:-nunit-mstest-xunit

⇱ Test Runner Integrations: NUnit, MsTest, Xunit | Accenture/Ocaramba | DeepWiki


Loading...
Last indexed: 6 June 2026 (fb3580)
Menu

Test Runner Integrations: NUnit, MsTest, Xunit

Ocaramba is designed to be test-runner agnostic, providing specialized integration projects for the three major .NET testing frameworks: NUnit, MsTest, and Xunit. While the core logic resides in OcarambaLite, these integration projects provide the necessary glue code, base classes, and data-driven helpers required to execute tests within specific runner environments.

Integration Architecture

The framework uses a provider-based approach where each test runner project implements a ProjectTestBase (inheriting from the framework's TestBase) to handle the lifecycle of the DriverContext.

Runner Logic Flow

The following diagram illustrates how different test runners interact with the Ocaramba core and Page Objects.

Diagram: Test Runner Data Flow


Sources: Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj36-37 Ocaramba.Tests.MsTest/Ocaramba.Tests.MsTest.csproj25-26 Ocaramba.Tests.Xunit/Ocaramba.Tests.Xunit.csproj36-37


Ocaramba.Tests.NUnit (Primary Integration)

Ocaramba.Tests.NUnit is the most feature-rich integration and serves as the primary reference implementation. It includes advanced data-driven testing, performance measurement, and file comparison capabilities.

Key Features

Data-Driven Implementation

The DataDrivenHelper uses XDocument for XML parsing and StreamReader for CSV files to yield TestCaseData objects compatible with NUnit's [TestCaseSource] Ocaramba.Tests.NUnit/DataDriven/DataDrivenHelper.cs65-99


Sources: Ocaramba.Tests.NUnit/DataDriven/DataDrivenHelper.cs65-99 Ocaramba.Tests.NUnit/Tests/HerokuappTestsNUnit.cs30-46


Ocaramba.Tests.MsTest

The MsTest integration is tailored for environments where Microsoft's native test runner is preferred. It focuses on standard MsTest data-driven patterns.

Configuration and Data

Sources: Ocaramba.Tests.MsTest/Ocaramba.Tests.MsTest.csproj1-61


Ocaramba.Tests.Xunit

The Xunit integration utilizes the TestFixture pattern to manage the browser lifecycle. Unlike NUnit or MsTest, Xunit does not use [SetUp] or [TearDown] attributes; instead, it relies on constructor and Dispose logic often encapsulated in a TestFixture class.

Xunit Test Structure

Tests use the [Fact] attribute for standard tests and inherit from ProjectTestBase to gain access to this.DriverContext Ocaramba.Tests.Xunit/Tests/ExampleTest2.cs28-33

Diagram: Xunit Entity Association


Sources: Ocaramba.Tests.Xunit/Tests/ExampleTest2.cs28-35 Ocaramba.Tests.Xunit/Ocaramba.Tests.Xunit.csproj18-21


Project Dependencies and Setup

Each runner project requires a specific set of NuGet packages and project references to function correctly within the Ocaramba ecosystem.

Shared Dependencies

All runner projects reference:

  1. OcarambaLite: The core engine Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj37
  2. Ocaramba.Tests.PageObjects: The shared library containing application-specific logic Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj36
  3. Selenium Drivers: Browser-specific drivers including ChromeDriver, GeckoDriver, and MSEdgeDriver Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj15-27

Comparison of Runner Packages

FeatureNUnit ProjectMsTest ProjectXunit Project
Test SDKMicrosoft.NET.Test.SdkMicrosoft.NET.Test.SdkMicrosoft.NET.Test.Sdk
AdapterNUnit3TestAdapterMSTest.TestAdapterxunit.runner.visualstudio
FrameworkNUnitMSTest.TestFrameworkxunit
Data FormatExcel (NPOI), CSV, XMLCSV, XMLTheory/MemberData (Standard Xunit)

Sources: Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj9-31 Ocaramba.Tests.MsTest/Ocaramba.Tests.MsTest.csproj14-21 Ocaramba.Tests.Xunit/Ocaramba.Tests.Xunit.csproj18-32

Adding New Tests

To add a new test to any of the runner projects:

  1. Inherit from ProjectTestBase to ensure the DriverContext is initialized correctly Ocaramba.Tests.NUnit/Tests/HerokuappTestsNUnit.cs33
  2. Initialize Page Objects by passing this.DriverContext to the constructor Ocaramba.Tests.NUnit/Tests/HerokuappTestsNUnit.cs39-40
  3. Use Verify.That for soft assertions to allow the test to continue after a failure while capturing screenshots Ocaramba.Tests.NUnit/Tests/HerokuappTestsNUnit.cs42-45
  4. Ensure Configuration Files (appsettings.json, nlog.config) are present in the output directory of the test project Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj45-59

Diagram: Page Object Initialization in Tests


Sources: Ocaramba.Tests.NUnit/Tests/HerokuappTestsNUnit.cs33-46 Ocaramba.Tests.NUnit/Ocaramba.Tests.NUnit.csproj45-59