@@ -0,0 +1,2550 @@
+package arez.integration.observe;%0A%0Aimport arez.Arez;%0Aimport arez.ArezContext;%0Aimport arez.Environment;%0Aimport arez.Function;%0Aimport arez.SafeFunction;%0Aimport arez.annotations.ArezComponent;%0Aimport arez.annotations.Executor;%0Aimport arez.annotations.Observe;%0Aimport arez.annotations.OnDepsChanged;%0Aimport arez.integration.AbstractArezIntegrationTest;%0Aimport java.util.ArrayList;%0Aimport java.util.Arrays;%0Aimport javax.annotation.Nonnull;%0Aimport org.testng.annotations.Test;%0Aimport static org.testng.Assert.*;%0A%0Apublic class TrackInEnvironmentTest%0A  extends AbstractArezIntegrationTest%0A%7B%0A  @ArezComponent%0A  public static abstract class TestComponent1%0A  %7B%0A    private final ArrayList%3CString%3E _steps;%0A%0A    TestComponent1( final ArrayList%3CString%3E steps )%0A    %7B%0A      _steps = steps;%0A    %7D%0A%0A    @Observe( executor = Executor.APPLICATION, requireEnvironment = true )%0A    public void render()%0A    %7B%0A      _steps.add( %22render1%22 );%0A      observeADependency();%0A    %7D%0A%0A    @OnDepsChanged%0A    final void onRenderDepsChanged()%0A    %7B%0A    %7D%0A%0A    @Observe( executor = Executor.APPLICATION, requireEnvironment = false )%0A    public void render2()%0A    %7B%0A      _steps.add( %22render2%22 );%0A      observeADependency();%0A    %7D%0A%0A    @OnDepsChanged%0A    final void onRender2DepsChanged()%0A    %7B%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void scenario()%0A  %7B%0A    final ArezContext context = Arez.context();%0A%0A    // Scheduler paused otherwise reactions will run in environment and upset our environment call count%0A    context.pauseScheduler();%0A%0A    final ArrayList%3CString%3E steps = new ArrayList%3C%3E();%0A    context.setEnvironment( new Environment()%0A    %7B%0A      @Override%0A      public %3CT%3E T run( @Nonnull final SafeFunction%3CT%3E function )%0A      %7B%0A        try%0A        %7B%0A          steps.add( %22EnvironmentStart%22 );%0A          return function.call();%0A        %7D%0A        finally%0A        %7B%0A          steps.add( %22EnvironmentEnd%22 );%0A        %7D%0A      %7D%0A%0A      @Override%0A      public %3CT%3E T run( @Nonnull final Function%3CT%3E function )%0A        throws Throwable%0A      %7B%0A        try%0A        %7B%0A          steps.add( %22EnvironmentStart%22 );%0A          return function.call();%0A        %7D%0A        finally%0A        %7B%0A          steps.add( %22EnvironmentEnd%22 );%0A        %7D%0A      %7D%0A    %7D );%0A%0A    final TestComponent1 component = new TrackInEnvironmentTest_Arez_TestComponent1( steps );%0A%0A    component.render();%0A%0A    assertEquals( steps, Arrays.asList( %22EnvironmentStart%22, %22render1%22, %22EnvironmentEnd%22 ) );%0A%0A    component.render2();%0A%0A    assertEquals( steps, Arrays.asList( %22EnvironmentStart%22, %22render1%22, %22EnvironmentEnd%22, %22render2%22 ) );%0A  %7D%0A%7D%0A

Add integration test for tracking observer