@@ -0,0 +1,2667 @@
+package havarunner;%0A%0Aimport com.google.common.collect.Lists;%0Aimport havarunner.annotation.Scenarios;%0Aimport org.junit.Test;%0Aimport org.junit.experimental.runners.Enclosed;%0Aimport org.junit.runner.RunWith;%0A%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0Aimport static havarunner.TestHelper.run;%0Aimport static org.junit.Assert.assertSame;%0A%0A@RunWith(Enclosed.class)%0Apublic class SameInstanceTest %7B%0A%0A    public static class when_the_test_has_multiple_scenarios %7B%0A%0A        static List%3CObject%3E instanceWhenMars = Lists.newArrayList();%0A        static List%3CObject%3E instanceWhenVenus = Lists.newArrayList();%0A%0A        @Test%0A        public void HavaRunner_calls_each_test_method_on_the_same_instance() %7B%0A            run(new HavaRunner(TestWithScenarios.class));%0A            assertSame(instanceWhenMars.get(0), instanceWhenMars.get(1));%0A            assertSame(instanceWhenVenus.get(0), instanceWhenVenus.get(1));%0A        %7D%0A%0A        static class TestWithScenarios %7B%0A%0A            private final String planet;%0A%0A            TestWithScenarios(String planet) %7B%0A                this.planet = planet;%0A            %7D%0A%0A            @Test%0A            void test() %7B%0A                if (planet.equals(%22mars%22)) %7B%0A                    instanceWhenMars.add(this);%0A                %7D else if (planet.equals(%22venus%22)) %7B%0A                    instanceWhenVenus.add(this);%0A                %7D else %7B%0A                    throw new IllegalStateException(%22Unrecognised planed %22 + planet);%0A                %7D%0A            %7D%0A%0A            @Test%0A            void another_test() %7B%0A                if (planet.equals(%22mars%22)) %7B%0A                    instanceWhenMars.add(this);%0A                %7D else if (planet.equals(%22venus%22)) %7B%0A                    instanceWhenVenus.add(this);%0A                %7D else %7B%0A                    throw new IllegalStateException(%22Unrecognised planed %22 + planet);%0A                %7D%0A            %7D%0A%0A            @Scenarios%0A            static Collection%3CString%3E scenarios() %7B%0A                return Lists.newArrayList(%22mars%22, %22venus%22);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static class without_scenarios %7B%0A        static Object instanceWhenMilkyway;%0A        static Object instanceWhenAndromeda;%0A%0A        @Test%0A        public void HavaRunner_calls_each_test_method_on_the_same_instance() %7B%0A            run(new HavaRunner(TestClass.class));%0A            assertSame(instanceWhenMilkyway, instanceWhenAndromeda);%0A        %7D%0A%0A        static class TestClass %7B%0A%0A            @Test%0A            void test() %7B%0A                instanceWhenAndromeda = this;%0A            %7D%0A%0A            @Test%0A            void another_test() %7B%0A                instanceWhenMilkyway = this;%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add SameInstanceTest