ImageVerifierCode 换一换
格式:PPT , 页数:46 ,大小:280.10KB ,
资源ID:373208      下载积分:2000 积分
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝扫码支付 微信扫码支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【http://www.mydoc123.com/d-373208.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Test Your ASP Apps with VSTS Web Tests and Load Tests.ppt)为本站会员(ideacase155)主动上传,麦多课文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知麦多课文库(发送邮件至master@mydoc123.com或直接QQ联系客服),我们立即给予删除!

Test Your ASP Apps with VSTS Web Tests and Load Tests.ppt

1、Test Your ASP.NET Apps with VSTS Web Tests and Load Tests,Benjamin Day http:/ http:/,About the speaker,Owner, Benjamin Day Consulting, Inc. Email: Web: http:/ Blog: http:/ Trainer Visual Studio Team System, Team Foundation Server Microsoft MVP for VSTS Microsoft VSTS/TFS Customer Advisory Council M

2、icrosoft Cloud Services Advisory Group Leader of Beantown.NET INETA User Group,What is a Web Test?,Unit test for exercising and validating an ASP.NET application Collection of web requests Typically represents a scenario through the web app Probably not a great candidate for Test-First Development V

3、alidation Rules to check the returned web page Extraction Rules extract values from a returned page for use in other parts of the test Recorded or coded Can be data-driven Building block for Load Tests,Demo: Create a basic WebTest,What can you add to a web test?,ASP.NET UI Requests Requests to a web

4、 page WebService Requests Microsoft says “Request to a web service” In reality, more like a chunk of text passed to an HTTP address Comments Transactions A subset of the web tests requests grouped together by name Used to get timing information portions of the test Calls to other web tests New for V

5、S2008,What can you add to a request?,HTTP Header Add a header and a value URL Query String Parameter POST Parameter File Upload Parameter Dependent Request(s) Request embedded into the page like an image () request By default, dependent requests are parsed and issued at runtime according to the Resp

6、onse Adding a dependent request forces a certain request to be made,Parameterization,Use context values to drive your requests and validations Minimizes hard coding Web server addresses for requests can be parameterized Parameterized values are stored in the test context Reference the values using d

7、ouble “squiggle bracket” syntax variable_name Allows you to pass in values from load tests Essential for data-driven web tests,Data-Driven Web Tests,Use an external data source to run your web test OLE DB source CSV XML Helps simulate multiple users Enables much more thorough tests Easy to do more c

8、omplex tests,Code Demo,Create a basic data-driven web test,Data-Driven Test Gotchas / Fixes,Sources are challenging to modify File-based (CSV, XML) use hard-coded paths Database connection string can only be replaced not modified Problem: what if your devs dont all have the same working directories?

9、 Problem: paths different during automated builds Problem: database might be different during automated builds Fixes: Reference file-based sources through a network share localhostWebTestDatasources Option: Adjust your “hosts” file C:WindowsSystem32driversetchosts Reference databases using “Trusted

10、Connection=true”,Data-Driven Web Test Best Practices,You should always be able to use version control to re-create a point-in-time version of your app This includes your unit tests If your tests are data-driven then the data source needs to be version controlled, too! You should be able to compile y

11、our app and run ALL the unit tests from an automatic build (continuous integration),How to get test data without much effort,Create a “DB Pro” project Visual Studio Team System 2008 Database Edition defines the structure of the database Option #1: Use a Test Data Generation Plan Option #1a: Put the

12、test data into a database and script it to a CSV Option #1b: Reference the test data directly in the database Option #2: Use “Post Deploy” Scripts to populate the database Database is your data source Compile / Deploy the database You can populate test data tables the database using “Post-Deployment

13、 Scripts” as part of the database “build”,Test Data Regular Expressions,Names: A-Zaeioua-z* Email Addresses: a-z0-9*a-z0-9*.(com|org|net|co.uk) Phone Numbers: (0-93)-0-93-0-94,Code Demo,Generate test data with DBPro Use SQL Server Management Studio to export to CSV Put CSV on a share Modify data sou

14、rce to reference the share,Web Test Properties,Stop On Error If true, the test stops running at the first error Default value is false User Name, Password Credentials for the request Basic auth or Windows Integrated auth Description Proxy Address of a proxy server for this request PreAuthenticate Se

15、nd the authentication in the header True, False,Request Properties,Url Url for the request Follow Redirects Method GET or POST Parse Dependent Requests Look for things like tags, style sheets requests, and download them Encoding Character format for the request Default is UTF-8,More Request Properti

16、es,Cache Control True = use locally cached version (IEs “Automatic” setting) False = Always download Think Time (seconds) Emulate a human reading/consuming the web page Timeout (seconds) How long before this request should fail? Record Results Record performance counter data when run from a load tes

17、t,Still More Request Properties,Version Version of HTTP to send: 1.0 or 1.1 Expected HTTP Status Code Default value = 0 200, 300 = OK 400, 500 = Error Expected Response URL,Validation & Extraction Rules,Rules,Validation Rules Check values in the response Can be “Global” to the web test Per request E

18、xtraction Rules Pull values from the response Put them into the Test Context for use in other requests,“Out of the box” Validation Rules,Form Field Validate a field for an expected value Field = Find Text Find a string anywhere in the Response Maximum Request Time Execution time in milliseconds Requ

19、ired Tag Html tag exists n times in the response Required Attribute Value Html tag exists with the expected attributes and values Response URL URL (after redirects) is same as during the recorded test,“Out of the box” Extraction Rules,Pull values from the response Test Context Extract Attribute Valu

20、e Extract Form Field Extract HTTP Header Gets the value for an HTTP Header Extract Regular Expression Use a regex to pull a value from the response Extract Text Using StartsWith and EndsWith Extract Hidden Fields,“Out of the box” rules are underwhelming,Not a bad starting point Missing some function

21、ality Example: cant validate/extract Label values A little confusing (maybe Im not that smart.)Good news: you can easily create your own,The Html Agility Pack,Free .NET Library to help parse/consume HTML http:/ Why do you need it? HTML is hard to parse Usually isnt valid XML (unclosed tags, case sen

22、sitivity problems) Simplifies custom web test rule development Add a reference to HtmlAgilityPack.dll from your custom rule assembly,HtmlAgilityPack Basics,HtmlAgilityPack namespace HtmlDocument Primary point of contact for working with the HTML Load() & LoadHtml() methods GetElementById() Fetches a

23、n HtmlNode (aka. html tag) by its “id” attribute value HtmlNode An element (aka. html tag) in the html InnerText property Retrieve the contents of the tag with any xml markup stripped out InnerHtml property Retrieve the raw XML/HTML contents of the tag,Create a New Web Test Validation Rule,Must be i

24、n a different DLL than the WebTests Microsoft.VisualStudio.QualityTools.WebTestFramework.dll C:Program FilesMicrosoft Visual Studio 9.0 Common7IDEPublicAssemblies Extend from ValidationRule Implement VS2005: RuleName, RuleDescription Properties Obsoleted in VS2008 VS2008: System.ComponentModel Displ

25、ayName(“name”), Description(“desc”) Method: Validate(),Custom Rules: ValidationEventArgs,Passed via the Validate() method Provides access to WebTestRequest WebTestResponse WebTest Set the error message via Message property Set pass/fail via IsValid property ValidationLevel,Code Demo,Ajax support Cre

26、ate a validation rule to validate an ASP.NET Label Create a validation rule to validate a ASP.NET GridView,Creating New Web Test Extraction Rule,Must be in a different DLL than the WebTests Microsoft.VisualStudio.QualityTools.WebTestFramework.dll C:Program FilesMicrosoft Visual Studio 9.0 Common7IDE

27、PublicAssemblies Extend from ExtractionRule Abstract class Implement VS2005: RuleName, RuleDescription Properties Obsoleted in VS2008 VS2008: System.ComponentModel DisplayName(“name”), Description(“desc”) Method: Extract(),Custom Rules: ExtractionEventArgs,Passed via the Extract() method Provides ac

28、cess to WebTestRequest WebTestResponse WebTest Success property (bool) Extract value(s) get set into the WebTestContext object via WebTest.Context.Add(string, string) method,Code Demo,Create an extraction rule to get an ASP.NET Labels value,WebTest Hassles,Data source management VS2005 version doesn

29、t do AJAX VS2008 does AJAX Doesnt run JavaScript Difficult to use “Cassini” Cassini = ASP.NET Development Web Server in Visual Studio Difficult to get the disk path to your web app difficult to start Cassini Best practice: use IIS App.config does not get loaded for non-coded web tests OUCH! Large-sc

30、ale html layout changes break tests,PLUGINS,Web Test Plugins,Allow you to hook into the Pre- and Post- web test execution events Similar to ClassInitialize & ClassCleanup Extend from WebTestPlugin class in Microsoft.VisualStudio.TestTools.WebTesting namespace of Microsoft.VisualStudio.QualityTools.W

31、ebTestFramework.dll Override PreWebTest() or PostWebTest() Class cannot be in the same project as the web test Downside: Cant access app.config values in the normal way,Web Test Request Plugin,External class (cannot be in the same project as the web test) Allow you to hook into the Pre- and Post- ex

32、ecution events Similar to TestInitialize & TestCleanup Extend from WebTestRequestPlugin class in Microsoft.VisualStudio.TestTools.WebTesting namespace of Microsoft.VisualStudio.QualityTools.WebTestFramework.dll Override PreRequest() and PostRequest() Downside: Cant access app.config values in the no

33、rmal way,Workaround for the app.config problem, Part 1,Load the app.config file ourselves and parse it http:/ PostID=122048 protected string GetConfigSetting(string key) tryExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();Assembly assembly = Assembly.GetExecutingAssembly();strin

34、g configFileName = new FileInfo(assembly.Location ).Name.Replace(“.dll“, “) + “.config“;configFileMap.ExeConfigFilename = configFileName; ,Workaround for the app.config problem, Part 2,. Configuration configObj = ConfigurationManager.OpenMappedExeConfiguration( configFileMap, ConfigurationUserLevel.

35、None);string val = configObj.ConnectionStrings.ConnectionStrings “conn_string_name“.ConnectionString;return val; ,Load Testing,Create a load test by choosing existing unit tests Unit Tests Web Tests Stress tests the application by running the load test using simulated users Visual Studio Test Load A

36、gent Allows you to enlist other computers in the load test Approximately 1000 simulated users per processor (Disclaimer: actual results may vary) CDW.com Price on 11/14/2008 $4716.99,Demo: Create A Load Test,Team BUILD,Web Tests & Team Build,Automatically deploy your web app to IIS from MSBuild Adju

37、st references to custom plugins, rules from MSBuild Run the Web Tests without a Test List (.vsmdi) Deploy test data for data sourcesBug in Team Build 2008 Cant run web tests or load tests from team build This has been resolved in VS2008 SP1,Refresher: Structure of your Team Build,Team Build director

38、y Off of root of your source tree TFSBuild.proj The build script (MSBuild) TFSBuild.rsp “Command line” arguments fed to the team build Example: /verbosity:diag,Team Build: Default Targets,BeforeEndToEndIteration / AfterEndToEndIteration BuildNumberOverrideTarget BeforeClean / AfterClean BeforeGet /

39、AfterGet BeforeLabel / AfterLabel BeforeCompile / AfterCompile BeforeTest / AfterTest BeforeDropBuild / AfterDropBuild Before/after the outputs are copied to the drop directory BeforeOnBuildBreak / AfterOnBuildBreak Before/after the work item is created,Code Demo,Make it work in Team Build Configure

40、 IIS as part of the build Using MSBuild Community Tasks http:/msbuildtasks.tigris.org/,Summary,Created web tests Data-driven web tests Web test plugins Validation Rules, Extraction Rules with HtmlAgilityPack Load Tests Team Build,About the speaker,Owner, Benjamin Day Consulting, Inc. Email: Web: http:/ Blog: http:/ Trainer Visual Studio Team System, Team Foundation Server Microsoft MVP for VSTS Microsoft VSTS/TFS Customer Advisory Council Microsoft Cloud Services Advisory Group Leader of Beantown.NET INETA User Group,

copyright@ 2008-2019 麦多课文库(www.mydoc123.com)网站版权所有
备案/许可证编号:苏ICP备17064731号-1