FAQ
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Jakarta-turbine Wiki" for change notification.

The following page has been changed by BradfordFolkens:
http://wiki.apache.org/jakarta-turbine/Turbine2/FAQ

The comment on the change is:
Added JUnit single setup/teardown suggestions

------------------------------------------------------------------------------

* If you are running Tomcat as a windows NT Service, check out this link: http://forum.java.sun.com/thread.jsp?thread=290568&forum=33&message=1211179

+ == Q: How can I setup Turbine once for my JUnit Test cases? ==
+
+ A: This can be accomplished using JUnit's TestSetup extension. In order to avoid copying the structure to each test case, create a superclass called BaseTurbineTest that you can perform callbacks to get the TestSetup.
+
+ Below is an example of a BaseTurbineTest class:
+ {{{
+ import junit.extensions.TestSetup;
+ import junit.framework.Test;
+ import junit.framework.TestCase;
+
+ import org.apache.turbine.util.TurbineConfig;
+
+ public class BaseTurbineTest extends TestCase
+ {
+ protected static Test getTurbineSetup(Test test)
+ {
+ TestSetup testSetup = new TestSetup(test)
+ {
+ private TurbineConfig config = null;
+
+ public void setUp() throws Exception
+ {
+ config = new TurbineConfig(".", "WEB-INF/conf/test/TurbineResources.properties");
+ config.initialize();
+ }
+
+ public void tearDown() throws Exception
+ {
+ config.dispose();
+ }
+ };
+
+ return testSetup;
+ }
+ }
+ }}}
+
+ Once you've setup this class, creating new tests is very quick and easy. Now we can ensure the Turbine framework starts up once for the TestCase below "MyTest" and still run setUp() and tearDown() code for each test. Check out the example:
+ {{{
+ import junit.framework.Test;
+ import junit.framework.TestSuite;
+
+ public class MyTest extends BaseTurbineTest
+ {
+ public static Test suite()
+ {
+ return getTurbineSetup(new TestSuite(MyTest.class));
+ }
+
+ public void setUp()
+ {
+ System.out.println("Set up.");
+ }
+
+ public void tearDown()
+ {
+ System.out.println("Tear down.");
+ }
+
+ public void test1()
+ {
+ }
+
+ public void test2()
+ {
+ }
+
+ public void test3()
+ {
+ }
+ }
+ }}}
+

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriesturbine
postedApr 21, '05 at 8:05a
activeApr 21, '05 at 8:05a
posts1
users1
websiteturbine.apache.org

1 user in discussion

Apache Wiki: 1 post

People

Translate

site design / logo © 2019 Grokbase