追求代码质量: 对 Ajax 应用程序进行单元测试[2]

发表于:2010-05-04来源:作者:点击数: 标签:代码质量单元AjaxAJAX
追求代码 质量 : 对 Ajax 应用程序进行 单元测试 [2] 软件测试 清单 1. 一个有效的 GWT 应用程序,但是如何测试它? public class DefaultModule implements EntryPoint { public void onModuleLoad() { Button button = new Button("Submit"); TextBox box =

  追求代码质量: 对 Ajax 应用程序进行单元测试[2]  软件测试

  清单 1. 一个有效的 GWT 应用程序,但是如何测试它?

  public class DefaultModule implements EntryPoint {

  public void onModuleLoad() {

  Button button = new Button("Submit");

  TextBox box = new TextBox();

  Label output = new Label();

  Label label = new Label("Word: ");

  HorizontalPanel inputPanel = new HorizontalPanel();

  inputPanel.setStyleName("input-panel");

  inputPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

  inputPanel.add(label);

  inputPanel.add(box);

  button.addClickListener(new ClickListener() {

  public void onclick(Widget sender) {

  String word = box.getText();

  WordServiceAsync instance = WordService.Util.getInstance();

  try {

  instance.getDefinition(word, new AsyncCallback() {

  public void onFailure(Throwable error) {

  Window.alert("Error oclearcase/" target="_blank" >ccurred:" + error.toString());

  }

原文转自:http://www.ltesting.net