Commits

Przemyslaw Galazka committed d75de73

Support for searching mocks candidates in abstract test classes - Added new test

  • Participants
  • Parent commits a1b48d8

Comments (0)

Files changed (1)

springockito-annotations/src/test/java/org/kubek2k/springockito/annotations/SpringockitoContextLoaderTest.java

         verify(outer).doSomething();
     }
 
-    public static class SomeTestClass {
+    @Test
+    public void shouldLoadMockBeanFormAbstractTestClass() throws Exception {
+        // given
+        SpringockitoContextLoader loader = new SpringockitoContextLoader();
+
+        // when
+        loader.processLocations(SomeTestClass.class);
+        ApplicationContext context = loader.loadContext("classpath:/mockContext.xml");
+
+        // then
+        OuterBean outerBean = (OuterBean) context.getBean("outerBean2");
+
+        // verification that it's a mock
+        verifyNoMoreInteractions(outerBean);
+
+    }
+
+    public static class SomeTestClass extends SomeAbstractTestClass {
+        @SuppressWarnings("unused")
+        @WrapWithSpy
+        private OuterBean outerBean;
+
         @SuppressWarnings("unused")
         @ReplaceWithMock
         private OuterBean outerBean1;
-
-        @SuppressWarnings("unused")
-        @WrapWithSpy
-        private OuterBean outerBean;
     }
 
+    public static class SomeAbstractTestClass {
+        @SuppressWarnings("unused")
+        @ReplaceWithMock
+        protected OuterBean outerBean2;
+    }
 
     public static interface X {
         public int hello();