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

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

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    軟件單元測試工具TestDriven.NET的點點認識

    發布: 2010-8-03 09:38 | 作者: 網絡轉載 | 來源: 領測軟件測試網采編 | 查看: 226次 | 進入軟件測試論壇討論

    領測軟件測試網

    NUnitForms從 命名上看,就知道它跟NUnit有關,沒錯,它是NUnit的一個WinFrom的擴展。它為Windows Forms應用程序提供單元測試和壓力測試,可以非常容易的用它為你的Windows Forms類進行自動化測試,它提供了一個Recorder Application,來記錄你的操作。我們編寫類似于如下代碼片斷的測試代碼:

      ButtonTester button = new ButtonTester(\"buttonName\", \"formName\");

      ControlTester textBox = new ControlTester(\"nameOfSomeTextBox\");

      Assertion.AssertEquals(\"defaultText\", textBox[\"Text\"];

      textBox[\"text\"] = \"newText\"

      或者類似于這樣的代碼進行操作記錄:

      //records button.Click() public void Click(object sender, EventArgs args){

      listener.FireEvent(TesterType, sender, \"Click\");

      }//records: comboBox.Enter(\"text\"); public void TextChanged(object sender, System.EventArgs e){

      listener.FireEvent(TesterType, sender, \"Enter\", ((ComboBox)sender).Text);

      }//records: comboBox.Select(3); //text of item 3 public void SelectedIndexChanged(object sender, System.EventArgs e){

      EventAction action = new EventAction(\"Select\", ((ComboBox)sender).SelectedIndex);

      action.Comment = ((ComboBox)sender).Text;

      listener.FireEvent(TesterType, sender, action);

      }

      對于NUnitForms,它還有一個兄弟工具叫NUnitASP,

      學習資源

      對于NUnitForms,仍然是沒有發現有好的中文資源,大家可以參考官方文檔。

      四.NUnitAsp

      NUnitAsp可以說是NUnitForms的兄弟,它也是一個NUnit的擴展,用來自動測試ASP.NET頁面。雖然NunitAsp可以完成一些ASP.NET頁面的自動化測試工作,但是在編寫測試用例的時候,如果界面上的元素比較多,編寫起來會非常的麻煩,這也是為什么NunitAsp一直處于大紫不紅的原因。它可以編寫如下代碼片斷的測試代碼: [Page]

      public void TestLayout(){

      TextBoxTester name = new TextBoxTester(\"name\", CurrentWebForm);

      TextBoxTester comments = new TextBoxTester(\"comments\", CurrentWebForm);

      ButtonTester save = new ButtonTester(\"save\", CurrentWebForm);

      DataGridTester book = new DataGridTester(\"book\", CurrentWebForm);

      Browser.GetPage(\"http://localhost/GuestBook/GuestBook.aspx\");

      AssertVisibility(name, true);

      AssertVisibility(comments, true);

      AssertVisibility(save, true);

      AssertVisibility(book, false);

      }public void TestSave(){

      TextBoxTester name = new TextBoxTester(\"name\", CurrentWebForm);

      TextBoxTester comments = new TextBoxTester(\"comments\", CurrentWebForm);

      ButtonTester save = new ButtonTester(\"save\", CurrentWebForm);

      DataGridTester book = new DataGridTester(\"book\", CurrentWebForm);

      Browser.GetPage(\"http://localhost/GuestBook/GuestBook.aspx\");

      name.Text = \"Dr. Seuss\" comments.Text = \"One Guest, Two Guest! Guest Book, Best Book!\" save.Click();

      }

      學習資源

      跟自己的兄弟NUnitForms一樣,仍然沒有好的中文文檔,有興趣的朋友可以參考‘NUnitAsp的官方文檔,相對來說還是比較全的,有很多的教程。

      總結

      對于單元測試工具,就簡單的介紹這么多,我個人還是推薦使用TestDriven.Net的個人版,至于后面兩個NUnit的擴展,大家可以參考一下,在實際開發中用它們來測試會很麻煩,至少我目前不敢去做這個嘗試。還有一個非常值得推薦的單元測試工具Mbunit,有興趣的朋友可以關注一下,我對它了解并不多。

      評論:

      頁面測試,可以關注一下 watiN,他可控制到 dialog/frame/js的alert/confirm 的測試。

      http://watin.sourceforge.net/

      單元測試的部份,我們是用 NUnitLite。

      http://www.codeplex.com/NUnitLite

      功能少nunit很多-_-,但他可以測試 web site project 里app_code里的cs。

      符合工作的需求,也可參考看看。

      對于Mobile的單元測試工具,恐怕很難找,因為netcf對于反射支持有限,而像NUnit這樣的工具也用到了反射。最典型的例子就是NDoc,這個對netcf有的時候就愛莫能助了。

      ReSharper UnitRun

      \"is a free add-in for Microsoft Visual Studio 2005 that allows you to automatically run and profile unit tests. This user-friendly tool detects test fixtures of the supported unit testing frameworks and lets you run or profile them right from the code editor or from Visual Studio\'s Solution Explorer. \"

      免費但不是開源的...

      http://www.jetbrains.com/unitrun/

      VS2007 將支持Mobile 系統的 unit test, 請大家關注。

      另外,VS2005 database professsional 版本已經發布,支持SQL的單元測試,請大家試用。

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    22/2<12

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品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>