Announcement Announcement Module
Collapse
No announcement yet.
Adding a JUnit Test class for webflow Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding a JUnit Test class for webflow

    I have yet to use junit *gasp*. Yeah its sad but true. Anybody know where a good reference on how to setup tests for a spring webflow project (one that uses eclipse would be even better). I understand the basics of setting up a test class to test another class, but I am having trouble wrapping my head around creating a test class that travels through the flow. I made the following class (copied from the api and modified for my use):

    Code:
    package com.xactsites.producty.tests;
    
    import org.springframework.webflow.execution.ViewSelection;
    import org.springframework.webflow.execution.support.ApplicationView;
    import org.springframework.webflow.test.MockParameterMap;
    import org.springframework.webflow.test.execution.AbstractXmlFlowExecutionTests;
    import org.springframework.webflow.definition.registry.FlowDefinitionResource;
    
    public class InterviewFlowTests extends AbstractXmlFlowExecutionTests
    {
    	protected FlowDefinitionResource getFlowDefinitionResource() 
    	{
            return createFlowDefinitionResource("src/mypath/to/flow.xml");
        }
    
        public void testStartFlow() 
        {
            startFlow();
            assertCurrentStateEquals("ownerinfo");
        }
    
        public void testDisplayCriteriaSubmitSuccess() 
        {
            startFlow();
            MockParameterMap parameters = new MockParameterMap();
            parameters.put("XT_NAME", "tad");
            parameters.put("XT_YEAR_BUILT", "2002");
            ViewSelection view = signalEvent("next", parameters);
            assertCurrentStateEquals("homeinfo");
        } 
    
    }
    Now I am confused as to how to get this to run using eclipse. Yes its a newbie question and I want to learn more so just direct me to some good references and I will do all the learning. I have found plenty of junit tutorials but still do not understand how to get it working with spring webflow. Thanks in advance.

  • #2
    What problems are you having when running the example?

    Does it run at all?
    Is there an exception?

    Be more specfic about your problems please.

    Comment


    • #3
      sorry

      Sorry about that. I am not sure how to run it. What I am asking for is some tutorial or explaination on how to take this class an turn it into a junit test in eclipse. Its not getting any errors because I simply don't know where to start. How do I add it as a junit test in eclipse.

      Comment


      • #4
        next

        Wow...that was incredibley simple! Right click...run as junit test...really complicated *cough*. But now it can't find the class.

        Code:
        Class not found com.xactsites.producty.tests.InterviewFlowTests
        java.lang.ClassNotFoundException: com.xactsites.producty.tests.InterviewFlowTests
        	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        	at java.security.AccessController.doPrivileged(Native Method)
        The package structure is correct, perhaps I am missing some setup step.

        Comment


        • #5
          I suggest you go to the eclipse or myeclipse website and look for help/guides there..

          Comment


          • #6
            I have gone through a bunch of them but still have a number of issues. I finally go frustrated enough to just use ant to do my junit testing and it is working perfectly. Thanks for your responses...sorry I brought it up here in the webflow forum...probably should have gone elsewhere.

            Comment

            Working...
            X