Announcement Announcement Module
Collapse
No announcement yet.
Very slow unit tests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Very slow unit tests

    Hi.
    I'm not sure if this is really an issue since I haven't been using webflow for a long time yet. But I started testing my flows today and I'm experiencing test times I'm not used to. I have four test methods at the moment and the times are 12 seconds, 12 seconds, 5 seconds and 5 seconds (from the top).
    I disabled the logger to make sure that's not part of the problem but the test times stayed the same.

    My first two tests call methods so I thought I'd comment them out for testing and indeed the other two tests didn't take 12 seconds but 7 and 10.
    So I can see a difference between calling a method and not calling one and also it seems to make a huge difference if the method is called near the loading of the framework.
    But in the end 5 seconds for completing a simple transition is too much. I can watch flash videos faster!

    Here's a part of my test file:
    Code:
    public class ManagerFlowTest extends AbstractXmlFlowExecutionTests{
    
    	private DataManager dataManager;
    	
    	protected void setUp() {
    			this.dataManager = new DataManager();
    		    }
    	 
    	@Override
    	protected FlowDefinitionResource getResource(
    			FlowDefinitionResourceFactory resourceFactory) {
    		return resourceFactory.createFileResource(
    				"src/main/webapp/WEB-INF/flows/manager-flow.xml");
    	}
    	
    	@Override
    	protected void configureFlowBuilderContext(MockFlowBuilderContext builderContext) {
    	    builderContext.registerBean("dataManager", dataManager);
    	}
    
    	
    	//takes 12 seconds
    	public void testStartManagerFlow() {
    		MutableAttributeMap input = new LocalAttributeMap();
    		MockExternalContext context = new MockExternalContext();
    		
    		startFlow(input, context);
    		assertCurrentStateEquals("manager_welcome");
    	}
    	
    	//takes 12 seconds
    	public void testNewDossierAction(){
    		MockExternalContext context = new MockExternalContext();
    	    context.setEventId("new_dossier_action");
    	    context.setCurrentUser("testUser");
    	    
    	    setCurrentState("manager_welcome");
    	    resumeFlow(context);
    	    assertCurrentStateEquals("view_dossier");
    
    	}
    	
            //takes 5 seconds or 7 seconds if first two tests are commented out
            //this is a simple transition without any actions in between, no 
            //calls to methods or anything similar
    	public void testAdvancedSearchAction(){
    		MockExternalContext context = new MockExternalContext();
    	    context.setEventId("advanced_search_action");
    	    
    	    setCurrentState("manager_welcome");
    	    resumeFlow(context);
    	    assertCurrentStateEquals("advanced_search");
    	}
    	
    	 //takes 5 seconds or 10 seconds if first two tests are commented out
            public void testDoSearchAction(){
    		MockExternalContext context = new MockExternalContext();
    	    context.setEventId("do_search_action");
    	    
    	    setCurrentState("manager_welcome");
    	    resumeFlow(context);
    	    //runs through "do_search" action state
    	    assertCurrentStateEquals("search_results");
    	}
    
    }
    Does anyone have a hint to why I'm experiencing this?
    Last edited by theseion; Apr 7th, 2009, 07:02 AM. Reason: entered some comments

  • #2
    Update: My problem might be database related. Since DataManager is a facade that in turn calls some DAOs. I'll try to figure out how to get around this and then post what I've found out.

    Comment


    • #3
      Ok. After creating an mock object of the DataManager with
      Code:
      this.dataManager = EasyMock.createMock(DataManager.class);
      the init process still takes 7 seconds but every other test runs at normal speed (far below a second)

      Thanks to all who wasted their time on me...

      Comment

      Working...
      X