Announcement Announcement Module
Collapse
No announcement yet.
Unit Testing with mocks Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unit Testing with mocks

    Hi

    SO I have several tests working with my web flow.

    The first test I wrote, I had this section in my test (overriding AbstractXmlFlowExecutionTests, of course). I am using JMock but that is incidental.

    Code:
    @Override
    protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
    	final MyService myService = mockery.mock(MyService .class);
    mockery.checking(new Expectations() {{
    	    	exactly(1).of(myService).doStuff();will(returnValue(something));
    	    }});
    
    		builderContext.registerBean("myService", myService );
    	}
    So this covered what happened upon entry to the flow, I wanted one call to something that happens on-entry. It only happens once.

    All good so far. Now for the test on the next transition. I want to add some additional expectations within the the new test itself. So how can I get the mocked service in the new test ?

    Or do I really have to assert all my expectations in the configureFlowBuilderContext method ? This is what I have done to date but it means that I tend to end up with more test case classes than I might otherwise have.



    Cheers

    Chris
    Last edited by chrisfaulkner; Mar 30th, 2011, 05:29 AM. Reason: Inadvertent form submission !
Working...
X