[CUBBY-57] Actionの単体テストがやりやすい仕組みを用意する Created: 2008-01-05 Updated: 2008-01-13 Resolved: 2008-01-13 |
|
Status: | Closed |
Project: | Cubby |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | 1.0.0-RC1 |
Type: | Improvement | Priority: | Major |
Reporter: | agata | Assignee: | agata |
Resolution: | Fixed | Votes: | 0 |
Labels: | None |
Description |
http://jfut.featia.net/diary/20071231.html#p01 その他便利なものがあれば。 |
Comments |
Comment by agata [ 2008-01-13 ] |
パスの内部フォワードおよびActionProcesserを使って、 CubbyTestCase#processAction |
Comment by agata [ 2008-01-07 ] |
ログインせずにコメントしていました。上記コメントは全てagataです。 |
Comment by Anonymous [ 2008-01-07 ] |
テスト少しプラスしました。Actionのテストの感じはつかめてきました。 アクションメソッドの呼び出しにテストの時のみAOPとかで「ActionContextInitializeInterceptor」のようなものがかませれば初期化の問題は解決しそうな気がします。 |
Comment by Anonymous [ 2008-01-07 ] |
以下のようなコードで通るようになりました。 LoginActionTest.java public class LoginActionTest extends CubbyTestCase { private LoginAction action; private ActionContext actionContext; protected void setUp() throws Exception { include("app.dicon"); } public void testIndex() throws Exception { actionContext.initialize(new ActionDefImpl(getComponentDef(LoginAction.class), LoginAction.class.getMethod("index", new Class[0]))); assertPathEquals(Forward.class, "/todo/login.jsp", action.index()); } public void testLogin() throws Exception { actionContext.initialize(new ActionDefImpl(getComponentDef(LoginAction.class), LoginAction.class.getMethod("process", new Class[0]))); assertPathEquals(Forward.class, "/todo/login.jsp", action.process()); assertEquals(2, action.getErrors().getFields().size()); assertTrue(action.getErrors().getFields().containsKey("userId")); assertTrue(action.getErrors().getFields().containsKey("password")); } } |
Comment by Anonymous [ 2008-01-07 ] |
ひとまずcubby-examplesのほうに、CubbyTestCase, HelloActionTest, LoginActionTestをコミットしました。 |