• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 追求代碼質量: 使用 TestNG-Abbot 實現自動化 GUI 測試[4]

    發表于:2010-05-04來源:作者:點擊數: 標簽:代碼質量自動化GUIgui
    追求代碼 質量 : 使用 TestNG-Abbot 實現自動化 GUI 測試[4] 軟件測試 測試意外場景 當然,如果我非常希望驗證我的 Word Finder GUI,我必須確保在用戶執行意外操作時 —— 程序能夠正常工作,比如在輸入單詞之前按下 Find Word 按鈕,或者情況更糟,比如他

      追求代碼質量: 使用 TestNG-Abbot 實現自動化 GUI 測試[4]   軟件測試

      測試意外場景

      當然,如果我非常希望驗證我的 Word Finder GUI,我必須確保在用戶執行意外操作時 —— 程序能夠正常工作,比如在輸入單詞之前按下 Find Word 按鈕,或者情況更糟,比如他們輸入了一個無效的單詞。舉例來說,如果用戶沒有向文本字段輸入內容,GUI 應該顯示特定的信息,如清單 4 所示:

      圖 4. 糟糕的極端例子

      當然,使用 TestNG-Abbot 測試這種情況非常簡單,不是嗎?我所做的僅僅是將空值傳送到 TextComponentFixture 中,按下按鈕(通過對 ButtonFixture 使用 click 方法)并插入 “Please enter a valid word” 響應!

      清單 4. 測試一個極端例子:如果有人沒有輸入單詞就按下了按鈕該怎么辦?

      @Test

      public void assertNoWordPresentInvalidText() {

      TextComponentFixture text1 = new TextComponentFixture(this.fixture,

      "wordValue");

      text1.enterText("");

      ButtonFixture bfix = new ButtonFixture(this.fixture, "findWord");

      bfix.click();

      LabelFixture fix = new LabelFixture(this.fixture, "definition");

      fix.shouldHaveThisText("Please enter a valid word");

      }

      如清單 4 所示,一旦理解了獲得所需 GUI 組件的引用時,事情并不是很困難。最后一步是檢驗其他 糟糕的極端例子 —— 輸入了無效的單詞。這個過程與 清單 1 和 清單 3 非常相似:僅僅是將所需的 String 傳遞到 TextComponentFixture 對象,單擊,然后插入特定的文本。如清單 5 所示:

      清單 5. 輕松驗證另一個極端例子!

      @Test

      public void assertNoWordPresentInvalidText() {

      TextComponentFixture text1 = new TextComponentFixture(this.fixture,

      "wordValue");

      text1.enterText("Ha77");

      ButtonFixture bfix = new ButtonFixture(this.fixture, "findWord");

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>