我目前正在构建一个使用GWT,GWTP的web应用程序。
我有些关于测试的问题:
谢谢。
发布于 2011-12-11 14:52:18
谷歌发布了一个关于在GWT中使用不同测试方法的伟大的文章。一定要去看看。就我个人而言,我在测试诸如业务逻辑之类的后端内容时使用JUnit,从浏览器的角度测试UI和整个应用程序时使用硒。
发布于 2012-08-27 14:16:03
演示者可以很容易地使用朱基托进行单元测试。下面是一个使用Jukito测试演示者的快速示例。
@RunWith(JukitoRunner.class)
public class ShowCommentsPresenterTest {
@Inject
private ShowCommentsPresenter showCommentsPresenter;
@Inject
private PlaceManager placeManager;
@Test
public void onReset_PlaceRequestHasNoShowId_ShouldHideView() {
//given
when(placeManager.getCurrentPlaceRequest()).thenReturn(new PlaceRequest());
//when
showCommentsPresenter.onReset();
//then
verify(showCommentsPresenter.getView()).hide();
}
@Test
public void onReset_PlaceRequestHasAShowId_ShouldDisplayView() {
//given
String someShowId = "12345";
when(placeManager.getCurrentPlaceRequest()).thenReturn(new PlaceRequest()
.with(ParameterTokens.getShowId(), someShowId));
//when
showCommentsPresenter.onReset();
//then
verify(showCommentsPresenter.getView()).display();
}
}在GWTP的哲学中,观点不应该被直接测试.使用来自演示者的哑视图,可以通过在演示者上进行单元测试来测试大部分逻辑。像Selenium这样的工具更适合测试UI的交互性。
https://stackoverflow.com/questions/8461185
复制相似问题