📄 testhelloactionmultiple.java
字号:
package hello.mocktest;
import servletunit.struts.MockStrutsTestCase;
public class TestHelloActionMultiple extends MockStrutsTestCase {
public TestHelloActionMultiple(String testName) { super(testName); }
public void testNoParameters() {
// Basic test to illustrate functionality
setRequestPathInfo("/HelloWorld");
actionPerform();
verifyInputForward();
// Test Form Bean validations
verifyActionErrors(new String[] {"hello.no.username.error"});
}
public void testBadPerson() {
// Now test Talking to the Bad Person ("Monster")
addRequestParameter("userName","Monster");
setRequestPathInfo("/HelloWorld");
actionPerform();
verifyForward("SayHello");
verifyActionErrors(new String[] {"hello.dont.talk.to.monster"});
}
public void testHappyPath() {
// Now test the "Happy Path"
addRequestParameter("userName","Weiqin");
setRequestPathInfo("/HelloWorld");
actionPerform();
verifyForward("SayHello");
verifyNoActionErrors();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -