asp.net ui 工具測試

來源:互聯網
上載者:User

asp.net ui 工具測試

當你測試的使用者介面,你正在測試人類活動。正因為如此,你應該讓電腦執行的任務

是很好的,你應該執行的任務的類型,你是好惹的。當開發人員和測試人員首先對可用

於測試的UI工具學習,他們往往認為一切都可以實現自動化,這是很遠的現實。第7章本

書的測試ASP.NET Web應用程式[,由傑夫McWherter和本廳(書號:978-0-470-49664-0

,Wrox出版社,2009年,著作權威利出版公司)]關於深入會談,手工測試但現在重要的是

我們瞭解,手動測試仍是一個測試周期非常重要的測試紀律。

 

弗雷德裡克布魯克斯教授在題為“沒有銀彈 - 本質和軟體工程事故,”1987年的軟體開

發人員的檔案,沒有在軟體開發銀彈,這意味著,沒有一個工具,可以解決整個工作你

希望完成。介面測試不應該被認為是最終所有即將所有的測試。當使用者介面進行適當的

測試是一個非常強大的測試載入器。

在您實現使用者介面自動化測試的重要性,下一個最重要的決定提出的,是你的工具將使

用建立的測試。有三種思想流派如何測試使用者介面。

類比瀏覽器

這是一個無頭一套指令碼發送的請求來類比瀏覽器相同類型的,但措施的回應時間,而不

內容表述,被送回。這種類型的UI測試是偉大的發現在Web應用的瓶頸。這一類型的測試

的缺點是,你不是研究和驗證實驗的反應情況。這種類型的測試只能用於量,壓力和負

載測試方案。

網路容量分析工具(冷原子捕集)是一個輕量級的HTTP負載產生工具,目的是類比的並

發使用者數,提出請求到一個網站。冷原子捕集用簡單的指令碼來類比瀏覽器和充分行使一

個網站:

新的交易

    的classid = 1

    新請求的HTTP

        動詞=“獲得”

        網址=“http://www.google.com”
using NUnit.Framework;

using System.Net;

using System.IO;

 

namespace ParseHttp

{

    [TestFixture]

    public class ParseHttp

    {

        [Test]

        public void Should_Navigate_To_Google_And_Return_Results_For_AspNet()

        {

            string urlToTest =

            "http://www.google.com/search?

hl=en&rlz=1G1GGLQ_ENUS295&q=asp.net&btnG=Search";

            string result = GetPage(urlToTest);

            Assert.IsTrue(result.IndexOf("The Official") >0, "Asp.net Page

");

        }

 

        private string GetPage(string urlToTest)

        {

            // create a web client object to load the page from local server

            WebClient client = new WebClient();

            string result = string.Empty;

 

            // dump the contents of the page we navigated to into a stream

            using (StreamReader reader = new

StreamReader(client.OpenRead(urlToTest)))

            {

                result = reader.ReadToEnd();

            }

 

            return result;

        }

    }

}

瀏覽器

在這個介面測試方法(如在未來上市),該測試將開啟一個物理瀏覽器,執行的行為,

然後該測試將在測實驗證您輸入的標準為基礎的HTML。這種自動介面測試類型是手動測

試最接近你會得到。由於測試需要開啟瀏覽器,執行測試,並報告結果支援這一類型的

測試非常脆弱。這些類型的測試往往是複雜的,如果你的計劃是只壓力測試您的應用程

序這種類型的測試將是矯枉過正:


using NUnit.Framework;

using WatiN.Core;

using WatiN.Core.Interfaces;

 

namespace SimpleWatinTest

{

    [TestFixture]

    public class SimpleWatinTests

    {

        [Test]

        public void

Should_Click_Search_On_Google_And_Return_Results_For_AspNet()

        {

            using (IBrowser ie =

BrowserFactory.Create(BrowserType.InternetExplorer))

            {

                ie.GoTo("http://www.google.com");

                ie.TextField(Find.ByName("q")).Value = "asp.net";

                ie.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(ie.ContainsText

                ("The Official Microsoft ASP.NET Site"));

            }

        }

    }

}

using NUnit.Framework;

using WatiN.Core;

using WatiN.Core.Interfaces;

 

namespace SimpleWatinTest

{

    [TestFixture]

    public class SimpleWatinTests

    {

        [Test]

        public void

Should_Click_Search_On_Google_And_Return_Results_For_AspNet()

        {

            using (IBrowser ie =

BrowserFactory.Create(BrowserType.InternetExplorer))

            {

                ie.GoTo("http://www.google.com");

                ie.TextField(Find.ByName("q")).Value = "asp.net";

                ie.Button(Find.ByName("btnG")).Click();

                Assert.IsTrue(ie.ContainsText

                ("The Official Microsoft ASP.NET Site"));

            }

        }

    }

}

Below is a table of how HTML elements can be obtained using the WatiN

framework.WatiN HTML Mapping:

HTML ELEMENT WatiN Class Example
<a /> Link Ie.Link(linkId)
<button /> Button Ie.Button(buttonId)
<div /> Div Ie.Div(divId)
 
<form /> Form Ie.Form(formId)
<frame /> Frame
 Ie.Frame(frameId)
<iframe /> Frame Ie.Frame(iframeId)
<img /> Image Ie.Image(imageId)
<input type=button/> Button Ie.Button(buttonId)
<input type=checkbox/> CheckBox Ie.CheckBox(checkboxId)
<input type=file/> FileUpload Ie.FileUpload(fileuploadId)
<input type=image/> Image Ie.Image(imageId)
<input type=password/> TextField Ie.TextField(passwordId)
<input type=radio/> RadioButton Ie.RadioButton(radioId)
<input type=submit/> Button Ie.Button(submitId)
<input type=text/> TextField Ie.TextField(textId)
<label /> Label
 Ie.Label(elementId)
<option /> Option Ie.Select(selectId).Options
<p /> Para Ie.Para(pId)
<select /> Select Ie.Select(selectId)
<span />    
<table /> Table Ie.Table(tableId)
<tbody /> TableBody Ie.TableBody(tablebodyId)
Ie.Table(tableid).TableBodies
<td /> TableCell Ie.TableCell(tablecellId)
Ie.Table(TableId).TableRows[0].TableCells[0]
<textarea /> TextField Ie.TextField(textareaId)
<tr /> TableRow Ie.TableRow(tablerowId)
Ie.Table(TableId).TableRows[0]
All elements, also the ones not mentioned in this list Element and
ElementsContainer Ie.Element(elementId)
Ie.Element(tagname, elementId)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.