Reporting to ExtentReports

How to configure Atata reporting to ExtentReports.

Packages

In addition to Atata package, the Atata.ExtentReports package should be added to the project. It is also recommended to add Atata.NLog package, as it’s used in the sample project.

Configuration

In order to connect ExtentReports functionality to Atata, you need to call builder.UseExtentReports() in ConfigureAtataContextBaseConfiguration method of GlobalFixture class.

Here is the full code of GlobalFixture class for this tutorial:

GlobalFixture.cs

namespace AtataSamples.ExtentReports;

public sealed class GlobalFixture : AtataGlobalFixture
{
    protected override void ConfigureAtataContextBaseConfiguration(AtataContextBuilder builder)
    {
        builder.Sessions.AddWebDriver(x => x
            .UseStartScopes(AtataContextScopes.Test)
            .UseChrome(x => x
                .WithArguments(
                    "headless=new",
                    "window-size=1024,768",
                    "disable-search-engine-choice-screen"))
            .UseBaseUrl("https://demo.atata.io/"));

        builder.LogConsumers.AddNLogFile();
        builder.UseExtentReports();
    }

    protected override void ConfigureGlobalAtataContext(AtataContextBuilder builder) =>
        builder.SetUpWebDriversForUse();
}

Tests

Tests using own drivers

UsingOwnDriverTests.cs

namespace AtataSamples.ExtentReports;

public sealed class UsingOwnDriverTests : AtataTestSuite
{
    [Test]
    public void Test1() =>
        Go.To<HomePage>()
            .Report.Screenshot()
            .Header.Should.Contain("Atata");

    [Test]
    public void Test2() =>
        Go.To<HomePage>()
            .Report.Screenshot()
            .AggregateAssert(x => x
                .PageTitle.Should.Contain("Atata")
                .Header.Should.Contain("Atata"));
}

For testing purposes, screenshots are captured right after a navigation to the home page. Also when the test fails at any moment, a screenshot is captured as well.

Tests using same driver

In this test suite class we create one shared driver session via [StartSessionAndShare(typeof(WebDriverSession))] attribute for all class tests, do navigation once in SetUpFixture method, then every test starts with already navigated page and does its verification.

UsingOwnDriverTests.cs

namespace AtataSamples.ExtentReports;

[Parallelizable(ParallelScope.Self)]
[StartSessionAndShare(typeof(WebDriverSession))]
public sealed class UsingSameDriverTests : AtataTestSuite
{
    [OneTimeSetUp]
    public void SetUpFixture() =>
        Go.To<SignInPage>();

    [Test]
    public void Email() =>
        Go.On<SignInPage>()
            .Email.Should.BeVisible();

    [Test]
    public void Password() =>
        Go.On<SignInPage>()
            .Password.Should.BeVisible();
}

Results

After a tests run, the generated Extent HTML report can be found by relative path: \AtataSamples.ExtentReports\bin\Debug\net10.0\artifacts\{DATETIME_OF_RUN}\Report.html.

Extent Report