Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not familiar with Springockito, but it looks interesting for some narrow cases - namely integration testing with mocking just a bit. </p> <p>Anyway, it looks like for a straightforward use case you extend <a href="http://static.springsource.org/spring/docs/2.5.x/api/org/springframework/test/context/junit4/AbstractJUnit4SpringContextTests.html" rel="nofollow">AbstractJUnit4SpringContextTests</a>, you could also autowire ClassB in your test just like you do in ClassA. Then you could define your expected behavior for ClassB in your setup method.</p> <p>But I think that you need to set up some behavior for the ClassB bean before you get access to it in your setup method. In that case, you may need another bean to set up ClassB to do the expected behavior. So your testContext.xml would have something like this in it:</p> <pre><code>&lt;bean id="classA" class="com.jarvis.ClassA" depends-on="classBMockSetter" /&gt; &lt;mockito:mock id="classB" class="com.jarvis.ClassB" /&gt; &lt;bean id="classBMockSetter" class="com.jarvis.test.ClassBMockSetter"&gt; &lt;property name="classB" ref="classB" /&gt; &lt;/bean&gt; </code></pre> <p>The ClassBMockSetter would look something like:</p> <pre><code>public class ClassBMockSetter { private ClassB classB; public void setClassB(ClassB classB) { this.classB = classB; given(classB.foo()).willReturn(true); given(classB.bar()).willReturn(42); } } </code></pre> <p>I think that would work, but at that point, isn't it easier to just hand-code your mock ClassB?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload