我试图为挂毯 5.4页面呈现编写一个junit测试:
import org.apache.tapestry5.test.PageTester;
public class LoadTest {
private final String PAGE_NAME = "Login";
private final String APP_NAME = "";
private final String context = "src/main/webapp";
private PageTester tester;
@Before
public void init() {
String appPackage = "hu.webapp";
tester = new PageTester(appPackage, APP_NAME, context, AppModule.class);
}
@Test
public void confirmIndexIsLoaded() {
Document document = new Document();
document = tester.renderPage(PAGE_NAME);
assertNotNull(document);
}
}但我得到了一个RuntimeException,上面写着Request was not handled: 'Login' may not be a valid page name.
但这是我的well应用程序中的一个工作页面,它呈现得很好。
有人知道测试有什么问题吗?或者有人能给我看一个类似的测试代码吗?
提前感谢!
发布于 2017-03-17 15:10:52
一般来说,只有当您为页面的包通知错误的package时,才会发生这种情况。看一看(它对我有用):
import org.apache.tapestry5.test.PageTester;
public class LoadTest {
private final String PAGE_NAME = "Login"; // It has to be right too!
private final String APP_NAME = "app"; // Where was your app name?
private final String context = "src/main/webapp"; // Is that path right in your project?
private PageTester tester;
@Before
public void init() {
String appPackage = "hu.webapp"; // Check if that's really correct!!!
tester = new PageTester(appPackage, APP_NAME, context);
}
@Test
public void confirmIndexIsLoaded() {
Document document = tester.renderPage(PAGE_NAME);
assertNotNull(document);
}
}另外,检查您的app名称,它应该在您的web.xml中配置为Tapestry过滤器,如in,例如:
<filter>
<filter-name>app</filter-name>
<filter-class>org.apache.tapestry5.TapestryFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>app</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>https://stackoverflow.com/questions/42856240
复制相似问题