-
1. Re: JSFUnit design??
ssilvert Feb 23, 2009 12:17 PM (in response to dareurdream)setUp() is called before each test method. That is part of the JUnit TestCase API, so it is not something that JSFUnit has control of.
JSFUnit does control what happens when you create a new JSFSession. When a new JSFSession is created, the HttpSession is cleared and you are given a "fresh" browser instance from HtmlUnit. So you are in a state where you are a new user sending an initial request to your application. Most of the time that is what you want when you start a new test.
If you want to continue the same user session then code your test class so that it only has one test method:public class MyTest extends ServletTestCase { private JSFClientSession client; private JSFServerSession server; public void setUp() throws IOException { JSFSession jsfSession = new JSFSession("/index.faces"); this.client = jsfSession.getJSFClientSession(); this.server = jsfSession.getJSFServerSession(); } public static Test suite() { return new TestSuite( MyTest.class ); } public void testAlotOfStuffInASingleSession() throws IOException { stuff1(); stuff2(); stuff3(); } public void stuff1() throws IOException {// more testing goes here} public void stuff2() throws IOException {// more testing goes here} public void stuff3() throws IOException {// more testing goes here} }
Just don't start your "stuff" methods with the word "test". If you do, JUnit will call setUp() and then call that method.
Stan -
2. Re: JSFUnit design??
dareurdream Feb 24, 2009 6:46 AM (in response to dareurdream)Hi Stan,
Thanks for the clarification.
Can you also clarify the other doubt:-I believe that the jsfsession is synchronized automatically as and when there are any changes. Is that so?
Manish -
3. Re: JSFUnit design??
ssilvert Feb 24, 2009 7:02 AM (in response to dareurdream)There are no synchronized methods in JSFSession, JSFClientSession, or JSFServerSession. But I'm not sure if that's what you mean.
JSFSession is a session in the truest sense. If your browser view changes then you are going to be looking at the new page just as if you were a user.
Stan