Atata 1.3.0 is Released

September 17, 2019 by Yevgeniy Shunevych


Atata 1.3.0 is released with aggregate (multiple) assertion functionality.

Changelog

New Features

  • minor #299 Add 2 extra Warn methods to ILogManager
  • minor #300 Add 2 extra Warn methods to Report<TOwner>
  • minor #303 Add ResolveComponentFullName method to UIComponentResolver
  • minor #304 Add AssertionResults property to AtataContext
  • major #305 Aggregate (multiple) assertion functionality
  • major #306 Add FindByAltAttribute
  • major #307 Add ImageInput<TOwner> control
  • major #308 Add ImageInput<TNavigateTo, TOwner> control
  • minor #310 Add For property to Label<T, TOwner>

Changes and Enhancements

  • minor #297 Add and use InvokeStaticAsLambda extension methods for MethodInfo
  • minor #298 Add and use InvokeAsLambda extension methods for MethodInfo
  • minor #309 Add extra constructor to ScreenshotAttribute
  • minor #311 Support VerifyTitleSettingsAttribute at more metadata levels

Aggregate Assertion

Aggregate (multiple) assertion functionality was added to allow execution of several Should.* assertions, collect the failed results and produce a single exception containing a set of failed assertions. Each failed assertion in scope of aggregate assert is also written to log.

2 strategies/approaches of aggregate assertion were implement:

  • Native - default Atata approach. Should be used when you don’t use NUnit with Atata.
  • NUnit - uses Assert.Multiple and other related methods of NUnit to provide an NUnit’s assertion handling.

Custom approach can also be implemented by implementing IAggregateAssertionStrategy.

Usage

New AggregateAssert methods were added to PageObject<TOwner> and AtataContext.

Aggregate Assert Page Object

Go.To<SomeUserPage>()
    .AggregateAssert(x => x
        .ContactDetails.FirstName.Should.Equal("John")
        .ContactDetails.LastName.Should.Equal("Smith"));

Or:

Go.To<SomeUserPage>()
    .AggregateAssert(x =>
    {
        x.ContactDetails.FirstName.Should.Equal("John");
        x.ContactDetails.LastName.Should.Equal("Smith");
    });

Aggregate Assert Component

Go.To<SomeUserPage>()
    .AggregateAssert(x => x.ContactDetails, x =>
    {
        x.FirstName.Should.Equal("John");
        x.LastName.Should.Equal("Smith");
    });

Aggregate Assert Block

AtataContext.Current.AggregateAssert(() =>
{
    Go.To<SomeUserPage>()
        .ContactDetails.FirstName.Should.Equal("John")
        .ContactDetails.LastName.Should.Equal("Smith");

    // Do other assertions...
});

Configuration

The following methods are added to AtataContextBuilder for configuring aggregate assertion functionality:

public AtataContextBuilder UseAggregateAssertionExceptionType(Type exceptionType);

public AtataContextBuilder UseAggregateAssertionExceptionType<TException>()
    where TException : Exception;

public AtataContextBuilder UseAggregateAssertionStrategy(IAggregateAssertionStrategy strategy);

public AtataContextBuilder UseAggregateAssertionStrategy<TAggregateAssertionStrategy>()
    where TAggregateAssertionStrategy : IAggregateAssertionStrategy, new();

public AtataContextBuilder UseNUnitAggregateAssertionStrategy();

Apply NUnit Aggregate Assertion Strategy

When using NUnit, it is recommended to invoke UseNUnitAggregateAssertionStrategy() during AtataContext configuration in order to enable NUnit’s built-in multiple assert functionality. For other testing frameworks (xUnit, MSTest) the native Atata assertion functionality will work well by default.

AtataContext.Configure()
    // Do some initialization.
    .UseNUnitAggregateAssertionStrategy()
    .Build();