Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregate (multiple) assertion functionality #305

YevgeniyShunevych opened this issue Sep 13, 2019 · 0 comments


Copy link

commented Sep 13, 2019


The aggregate (multiple) assertion functionality should be implemented to be able to invoke several Should.* assertions, collect the failed results and produce a single exception containing a set of failed assertions.

Implement 2 strategies of aggregate assertion:

  • Atata default/native.
  • Using NUnit's Assert.Multiple and other related methods.

Every failed assertion in the scope of aggregate one is written to log.

Additions to AtataContext

The actual main aggregate assertion method:

public void AggregateAssert(Action action, string assertionScopeName = null);


Implement AggregateAssertionException that represents one or more errors that occur during an aggregate assertion. This is the default aggregate assertion exception type that can be replaced with custom one thru AtataContextBuilder.

Should have a constructor with IEnumerable<AssertionResult> results argument to build the aggregate message based on the list of results.

Additions to AtataContextBuilder

Add methods 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();

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.

Additions to PageObject<TOwner>

Below 2 methods provide aggregate assertion directly to the page object with support of fluent interface:

public TOwner AggregateAssert(Action<TOwner> action);

public TOwner AggregateAssert<TComponent>(Func<TOwner, TComponent> componentSelector, Action<TComponent> action);

Under the hood, the methods use AtataContext.AggregateAssert method.


Aggregate assert page object

    AggregateAssert(x => x.


    AggregateAssert(x =>

Aggregate assert component

    AggregateAssert(_ => _.ContactDetails, x =>

Aggregate assert section

AtataContext.Current.AggregateAssert(() =>

    // Do other assertions...
@YevgeniyShunevych YevgeniyShunevych added this to the 1.3.0 milestone Sep 13, 2019
@YevgeniyShunevych YevgeniyShunevych self-assigned this Sep 13, 2019
YevgeniyShunevych added a commit that referenced this issue Sep 13, 2019
…e (multiple) assertion functionality; Add 5 tests
@YevgeniyShunevych YevgeniyShunevych changed the title Add aggregate (multiple) assertion functionality Aggregate (multiple) assertion functionality Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.