VOOZH about

URL: https://deepwiki.com/Accenture/Ocaramba/3.1-projecttestbase-and-projectpagebase

⇱ ProjectTestBase and ProjectPageBase | Accenture/Ocaramba | DeepWiki


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

ProjectTestBase and ProjectPageBase

This page explains the base class hierarchy in Ocaramba, focusing on how ProjectTestBase manages the lifecycle of tests and how ProjectPageBase provides a foundation for Page Objects. These classes bridge the gap between the core OcarambaLite framework and specific test runner implementations (NUnit, MSTest, XUnit, and SpecFlow).

Base Class Hierarchy

Ocaramba utilizes a multi-layered inheritance structure to separate framework-level logic from project-specific configurations.

1. TestBase (Framework Level)

The TestBase class is the root of the hierarchy, providing common utilities for saving test details like screenshots and page sources upon failure via the SaveTestDetailsIfTestFailed method.

2. ProjectTestBase (Project Level)

ProjectTestBase is implemented within each test project (e.g., Ocaramba.Tests.NUnit, Ocaramba.Tests.Angular, Ocaramba.Tests.MsTest). It is responsible for:

3. ProjectPageBase (Project Level)

ProjectPageBase is the base class for all Page Objects. It receives the DriverContext via its constructor and exposes properties to allow interaction with web elements. For example, in the reference implementation, page objects like InternetPage take the DriverContext to initialize their state Ocaramba.Tests.MsTest/HerokuappTestsMsTest.cs42

Implementation Overview

Code Entity Relationship Diagram

The following diagram illustrates how these base classes interact with the DriverContext and the NUnit test runner.

Test Lifecycle and Context Flow


Sources: Ocaramba.Tests.NUnit/ProjectTestBase.cs37-125 Ocaramba.Tests.MsTest/ProjectTestBase.cs39-111 Ocaramba.Tests.Features/ProjectTestBase.cs39-143

ProjectTestBase Details

Initialization and Cleanup

Initialization varies by test runner. In NUnit, the driver starts once per class using OneTimeSetUp Ocaramba.Tests.NUnit/ProjectTestBase.cs71-82 In MsTest, the driver starts before every test method using TestInitialize Ocaramba.Tests.MsTest/ProjectTestBase.cs81-88

RunnerStart HookStop HookContext Class
NUnit[OneTimeSetUp][OneTimeTearDown]TestContext.CurrentContext
MsTest[TestInitialize][TestCleanup]Microsoft.VisualStudio.TestTools.UnitTesting.TestContext
SpecFlow[Before][After]ScenarioContext

Failure and Screenshot Logic

When a test fails, ProjectTestBase invokes SaveTestDetailsIfTestFailed. It checks both the runner's outcome and the VerifyMessages count in DriverContext Ocaramba.Tests.NUnit/ProjectTestBase.cs111-112

Data Flow: Failure Artifacts


Sources: Ocaramba.Tests.NUnit/ProjectTestBase.cs109-125 Ocaramba.Tests.MsTest/ProjectTestBase.cs94-111 Ocaramba.Tests.Features/ProjectTestBase.cs118-143

Extending for Custom Projects

Angular Project Customization

The Angular implementation of ProjectTestBase subscribes to the DriverOptionsSet event in its constructor Ocaramba.Tests.Angular/ProjectTestBase.cs49-52 This allows it to inject specific logging preferences for performance and browser logs before the driver is fully initialized Ocaramba.Tests.Angular/ProjectTestBase.cs140-149

SpecFlow (BDD) Integration

In Ocaramba.Tests.Features, ProjectTestBase uses the [Binding] attribute Ocaramba.Tests.Features/ProjectTestBase.cs38 It injects the ScenarioContext and stores the DriverContext within the scenarioContext dictionary Ocaramba.Tests.Features/ProjectTestBase.cs111 This allows CommonSteps to retrieve the active driver session for step execution via the scenarioContext Ocaramba.Tests.Features/StepDefinition/CommonSteps.cs47

ProjectBaseConfiguration

ProjectBaseConfiguration provides static access to project-specific settings by wrapping BaseConfiguration.Builder. It handles:

Sources: