Re: [Httpunit-develop] Keep the WebConversation state?
Brought to you by:
russgold
From: Stefan G. R. <Ste...@we...> - 2002-05-26 18:27:06
|
On Friday 24 May 2002 10:39, you wrote: > Im new to the HttpUnit test tool. > > After going through the tutorial and playing with some own tests I > haven't been able to figure out how to keep the state of the > WebConversation between the different tests in a TestCase. I've tried to > override the setUp() method but that method runs before every test in > the testcase. > > If one test changes the state of the WebConversation the next test > should be able to continue to do another test on that state of the > WebConversation. How do I accomplish that? > > /Daniel > Hi Daniel, I assume you talk about JUnit and HttpUnit in concerto. Best to avoid test cases depending on each other -- you'll run into trouble that's hard to track down. For example, TestSuite uses reflection to find the testXXX methods of a TestCase, but there's no guarantee of the order of the methods. Therefore, if you want a specific order of testXXX methods, you have to provide an implementation of the method suite(), which means you have to maintain the construction of the test suite -- something errorprone and better avoided. Can you refactor your testcode so you can call parts of your test? This leads to something like this: void partA() { // do the usual request/response stuff, some assertions, ... } void partB() { // do the usual request/response stuff, some assertions, ... } public void testStep1() { partA(); assert( /* outcome of first part */ ); } public void testStep2() { partA(); partB(); assert( /* outcome of second part */ ); } Hope this helps, ciao Stef |