package org.realityforge.arez.integration;

import org.realityforge.arez.ArezTestUtil;
import org.realityforge.braincheck.BrainCheckTestUtil;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;

@SuppressWarnings( "Duplicates" )
public abstract class AbstractArezIntegrationTest
{
  @BeforeMethod
  protected void beforeTest()
    throws Exception
  {
    BrainCheckTestUtil.resetConfig( false );
    ArezTestUtil.resetConfig( false );
  }

  @AfterMethod
  protected void afterTest()
    throws Exception
  {
    BrainCheckTestUtil.resetConfig( true );
    ArezTestUtil.resetConfig( true );
  }
}

@@ -48,42 +48,291 @@
 ort 
-org.realityforge.arez.ArezTestUtil
+java.util.ArrayList;%0Aimport java.util.stream.Collectors;%0Aimport javax.annotation.Nonnull;%0Aimport javax.annotation.Nullable;%0Aimport org.realityforge.arez.Arez;%0Aimport org.realityforge.arez.ArezTestUtil;%0Aimport org.realityforge.arez.Observer;%0Aimport org.realityforge.arez.ObserverError
 ;%0Aim
@@ -470,16 +470,51 @@
 eMethod;
+%0Aimport static org.testng.Assert.*;
 %0A%0A@Suppr
@@ -593,16 +593,129 @@
 nTest%0A%7B%0A
+  private final ArrayList%3CString%3E _observerErrors = new ArrayList%3C%3E();%0A  private boolean _ignoreObserverErrors;%0A%0A
   @Befor
@@ -867,161 +867,924 @@
 ;%0A  
-%7D%0A%0A  @AfterMethod%0A  protected void afterTest()%0A    throws Exception%0A  %7B%0A    BrainCheckTestUtil.resetConfig( true );%0A    ArezTestUtil.resetConfig( true );
+  _ignoreObserverErrors = false;%0A    _observerErrors.clear();%0A    Arez.context().addObserverErrorHandler( this::onObserverError );%0A  %7D%0A%0A  protected void onObserverError( @Nonnull final Observer observer,%0A                                  @Nonnull final ObserverError error,%0A                                  @Nullable final Throwable throwable )%0A  %7B%0A    if ( !_ignoreObserverErrors )%0A    %7B%0A      final String message = %22Observer: %22 + observer.getName() + %22 Error: %22 + error + %22 %22 + throwable;%0A      _observerErrors.add( message );%0A      System.out.println( message );%0A    %7D%0A  %7D%0A%0A  @AfterMethod%0A  protected void afterTest()%0A    throws Exception%0A  %7B%0A    BrainCheckTestUtil.resetConfig( true );%0A    ArezTestUtil.resetConfig( true );%0A    if ( !_ignoreObserverErrors && !_observerErrors.isEmpty() )%0A    %7B%0A      fail( %22Unexpected Observer Errors: %22 + _observerErrors.stream().collect( Collectors.joining( %22%5Cn%22 ) ) );%0A    %7D
 %0A  %7D

Make sure tests fail if unexpected observer errors occur