Annotation Type TestManagedMock


  • @Target({FIELD,PARAMETER})
    @Retention(RUNTIME)
    @Documented
    public @interface TestManagedMock
    This annotation is used to indicate that a field or a parameter has to be mocked and then registered into the bean container used in the test before executing that test.

    If the test class declares several annotated fields having a common type among their ancestor, then the fields will be registered for that type and they could be get by using the TestBeanContainer.getAllBeansByType(Class, Annotation...) method. In that case, the call of TestBeanContainer.getBeanByType(Class, Annotation...) method with that type as parameter will throw an exception.

    If the annotation is applied to a parameter, then a bean of the parameter type is first looking for in the bean container used in the tests. If no such bean is found, then type is mocked, the mock is registered into the bean container and finally it is passed as parameter value. By using this annotation with the parameters, you can get any previously mocked bean to, for example, specify behaviours for the current test.t

    Author:
    mmoquillon
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean stubbed
      Is all of the methods of the mock should be stubbed?
    • Element Detail

      • stubbed

        boolean stubbed
        Is all of the methods of the mock should be stubbed? By default, a call to method of such an object is stubbed unless a behaviour was previously set to that method. To reverse this default behaviour, that is to say to allow a call to the methods invokes the real implementation of the called method, just set this property to false.
        Default:
        true