Evaluating Test Driven Development  [TDD] and Parameterized Unit Test [PUT] in .NET Web Platform<br />Prepared By: <br />M...
Topics Covered (i)<br />Abstract<br />Introduction<br />Why Test Driven Development?<br />TDD in .NET Environment<br /><ul...
Automated Web Testing– Selenium Vs. VS Web Testing
Unit Testing  - NUnit Vs. MS Test/MVC
Load Testing – VS Load Testing </li></ul>2<br />
Topics Covered (ii)<br />MVC .NET Test Suite<br />Parameterized Unit Testing (PUT) and Microsoft PEX<br />Strengths and Li...
Abstract (i)<br />Web technology has become widely accepted application platform this days. It brings the remote and distr...
Abstract (ii)<br />Application Test Driven Development or simply TDD is an evolutionary  approach to produce well tested r...
Introduction<br />This report is concentrated on Evaluating TDD in.NET environment. Web Application testing comprises of F...
What is Quality?<br />Quality is a term that stands for wide variety of aspects for a particular product or environment. H...
Quality Control Vs. Quality Assurance (i)<br />ISO 9001 Definition of<br />Quality Control<br />    The operational techni...
Quality Control Vs. Quality Assurance (ii)<br />	QC 			Vs. 			QA<br />Product 					Process<br />Reactive 					Proactive<br...
Test Driven Development<br />The term TDD has been around since NASA’ s Project, Mercury in 1960s. But, when Kent Beck and...
What is Test Driven Development?<br />Ref: A Survey of Evidence for Test Driven Development in Academia, Chetan Desai, Dav...
TDD – Industrial Case Studies@Microsoft<br />Two case studies were done at Microsoft to build empirical knowledge on the e...
Resulting improvement in software quality</li></ul>Evaluating the Efficacy of Test-Driven Development: Industrial Case Stu...
Windows networking team case study<br />Project A: Context Factor<br />Project A: Product Measure<br />Project A: Outcome<...
MSN Team case study<br />Project B: Context Factor<br />Project B: Product Measure<br />Project B: Outcome<br />Evaluating...
Can someone write my Test?<br />15<br />
TDD Tools Used in this Research (i)<br />Testing Frameworks: <br /><ul><li>Visual Studio Team System Unit Testing Framework
MVC .NET Testing Framework
Microsoft PEX</li></ul>Unit Testing: <br /><ul><li>NUnit
MVC .NET with MOCK
MS Test for Visual Studio</li></ul>16<br />
TDD Tools Used in this Research (ii)<br />Database Testing: <br /><ul><li>DBUnit .NET
DB Pro</li></ul>Automated Web Testing<br /><ul><li>Selenium
Visual Studio Automated Web Test</li></ul>Load/Stress Testing<br /><ul><li>Visual Studio Web Test
WCat 6.3 (x86)</li></ul>17<br />
Database Testing using DBUnit/DB Pro<br />18<br />
19<br />
What is Database Testing and Why? (i)<br />Database testing is a defined process to test database programmability objects....
DB Functions
Triggers
Rules
DB Assemblies</li></ul>20<br />
What is Database Unit Testing and Why?(ii)<br />So, the database unit tests could be created before hand to test the datab...
Feature/Functionality Test
Security Test
Stock data Test
Referential Integrity Constraints</li></ul>21<br />
What to Test?<br />Refactoring Databases: Evolutionary Database Design, by Scott W. Ambler and Pramod J. Sadalage, Addison...
Database Testing with DBUnit<br />DBUnit is a Open Source Database Testing Framework which was created by Manuel Laflamme<...
DBUnit Supported Databases<br />Ref: http://dbunit.wikidot.com/supportedrdbms<br />24<br />
Creating a DBUnit Test Class<br />Create a XML Dataset or Export Data from Databases<br />25<br />If the DBUnit Test Class...
Create a Test Class and Extend DBTestCase<br />using System;<br />using System.Data;<br />using System.Data.Sql;<br />usin...
Implement SetUp and TearDown<br /> [SetUp]<br />        public void SetUpTestCase()<br />        {<br />            mocks ...
Implement Test Method<br /> [Test]<br />        public void TestQuerySQLMessage()<br />        {<br />            string _...
Nunit/DBUnit Test Results<br />29<br />
DBUnit Benefits<br />DBUnit provides a stable framework to create and adopt Database Test cases with minimal effort<br />I...
DBUnit Limitations<br />Primary test data is XML but it is also possible to create test cases for standard databases <br /...
DBUnit – Short Demo<br />32<br />
Database Testing with MS DB Pro<br />The desire on the part of the database developer to use familiar T-SQL scripts to exp...
Two sample joined tables<br />34<br />
Stored Preocedure<br />CREATE PROCEDURE [dbo].[uspGetEmployeeManagers]<br />    @EmployeeID [int]<br />AS<br />BEGIN<br />...
DB Pro Test Results<br />36<br />
Adding a Data Generation Plan<br />37<br />
Selecting Tables for Test Data<br />38<br />
Data Column Configuration<br />39<br />
Generate Test Data before Unit Test<br />40<br />
DB Pro Benfits<br />Feature Tests, Schema Tests, Security Tests, Stock-Data Tests can be performed using DB Pro<br />Autom...
DB Pro Limitations<br />Only supported database is MS SQL Server<br />Need Visual Studio Team System - Database  Edition t...
DB Pro – Short Demo<br />43<br />
Web UI Testing using Selenium/Web Test<br />44<br />
Selenium for Web UI Testing<br />Selenium is an automated web user interface testing tools that provides the environment t...
Client: Client libraries to Build a Test Case Using NUnit and Mock</li></ul>45<br />
Selenium RC (Remote Control)<br />http://seleniumhq.org/projects/remote-control/<br />46<br />
Selenium Feature Matrix<br />Ref: http://wiki.openqa.org/pages/viewpage.action?pageId=763<br />47<br />
Start with Selenium Project in .NET<br />Download Selenium from <br />Download and Install NUnit or Any other testing suit...
Selenium Test Class<br />namespace MySeleniumTest<br />{<br />    [TestFixture]<br />    public class MySeleniumTest1<br /...
Selenium Benefits<br />Selenium could be used for the functional, regression, load testing of the web based applications. ...
Selenium Limitations<br />Setting up Selenium Test Suite is complex and step by step documentation is hard to find<br />On...
Selenium – Short Demo<br />52<br />
Visual Studio Web Test for UI Testing<br />The main purpose of Web UI testing is to uncover functional problems of a Web A...
Client Side Scripting/Security Settings/Validation
Session Variables and Timeouts</li></ul>53<br />
How it works?<br />The test harness system consists of three files (ASP .NET Page, Left.Html and Main.Html)<br />ASP .NET ...
Web Test Container – Main.Html<br /><html><br />  <head><br />    <script language="JScript"><br />vartimesAppLoaded = 0;<...
Visual Studio Web Test<br />56<br />
Adding Validation Rule<br />57<br />
Visual Studio Web Test Results<br />58<br />
Visual Studio Web UI Test Benefits<br />Creation of Test Cases for Multiple Browser  Support and browsers cross-compatibil...
Visual Studio Web UI Test Limitations<br />Need Visual Studio Team System to get the Web UI Testing Platform<br />Supports...
MS Web Test – Short Demo<br />61<br />
Microsoft MVC .NET Test Suite<br />62<br />
Web Application Testing<br />Web portal applications are being developed using MVC pattern paradigm.  MVC stands for Model...
All Business Logics are being hosted in “Model” component
And Managed by “Controller” component</li></ul>63<br />
MVC Pattern<br />http://msdn.microsoft.com/en-us/library/ms978748.aspx<br />64<br />
Web Portal Testing Constraints<br />Testing results may vary from Dev, Test and Production environment<br />Testing result...
MVC Project Layers<br />Abstract Layer<br />Business Layer<br />Data Layer<br />MVC project <br />66<br />
ASP .NET Framework<br />Modules<br />Globalization<br />Caching<br />Controls<br />Master Pages<br />Pages<br />Roles<br /...
ASP .NET MVC Framework<br />ASP.NET<br />Dynamic Data<br />Presentation<br />ASP.NET<br />WebForms<br />ASP.NET<br />MVC<b...
ASP.NET MVC Features (i)<br />Separation of application tasks (input logic, business logic, and UI logic), testability, an...
ASP.NET MVC Features (ii)<br />An extensible and pluggable framework<br />ASP.NET MVC framework components are easily cust...
Creating .NET Web App<br />71<br />
Creating a Unit Test Project<br />72<br />
Model-View-Controller (MVC)<br />73<br />
MVC Top Level Directories<br />74<br />
Typical MVC .NET Project Structure<br />75<br />
Change Password Method<br />        [Authorize]<br />        [HttpPost]<br />        public ActionResultChangePassword(Cha...
Change Password Test Method<br />        [TestMethod]<br />        public void ChangePassword_Post_ReturnsRedirectOnSucces...
Right Click and Create Test Method<br />78<br />
Membership Service Mocking<br /> private class MockMembershipService : IMembershipService<br />        {<br />            ...
Unit Test Results in .NET 3.5<br />80<br />
ASP.NET MVC Benefits<br />Resolving complexity by dividing an application into the model, the view, and the controller<br ...
ASP.NET MVC Limitations<br />Doesn’t use event model to preserve state over HTTP<br />Doesn’t use view state or server-bas...
MVC .Net – Short Demo<br />83<br />
Parameterized Unit Testing (PUT) and Microsoft Pex<br />84<br />
Unit Testing At a Glance<br />Three sections of Unit Tests:<br /><ul><li>Data
Method Sequence
Assertions</li></ul>void Add() {<br />int item = 3;<br />var list = new List();<br />list.Add(item); <br />var count = lis...
Incomplete Test Coverage with Fixed Data<br />list.Add(3); <br /><ul><li>Bad data may result in redundant, or worse, incom...
Fixed data values become invalid when product changes
Why choose a value which may not make sense?</li></ul>Ref : Parameterized Unit Testing: Principles, Techniques, and Applic...
What is Parameterized Unit Test?<br />Parameterized Unit Test is a Unit Test with Parameters<br />Separation of concerns<b...
PUT Sample<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microso...
Parameterized Unit Testing (PUT)<br />Some popular unit testing tools, like Junit, Nunit doesn’t support the automation of...
Upcoming SlideShare
Loading in …5
×

Evaluating Test Driven Development And Parameterized Unit Testing In Dot Net Presentation

3,439 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,439
On SlideShare
0
From Embeds
0
Number of Embeds
13
Actions
Shares
0
Downloads
0
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Evaluating Test Driven Development And Parameterized Unit Testing In Dot Net Presentation

  1. 1. Evaluating Test Driven Development [TDD] and Parameterized Unit Test [PUT] in .NET Web Platform<br />Prepared By: <br />Md. Fazlul Alam Chowdhury, <br />Email: mdfachowdhury@hotmail.com<br />Blog: http://fazlulchowdhury.blogspot.com<br />Date: 14.04.2010<br />1<br />
  2. 2. Topics Covered (i)<br />Abstract<br />Introduction<br />Why Test Driven Development?<br />TDD in .NET Environment<br /><ul><li>Database Unit Testing - DBUnit Vs. DB Pro
  3. 3. Automated Web Testing– Selenium Vs. VS Web Testing
  4. 4. Unit Testing - NUnit Vs. MS Test/MVC
  5. 5. Load Testing – VS Load Testing </li></ul>2<br />
  6. 6. Topics Covered (ii)<br />MVC .NET Test Suite<br />Parameterized Unit Testing (PUT) and Microsoft PEX<br />Strengths and Limitation of Testing Tools<br />Agile Influence in Visual Studio Team Foundation<br />Scope of Future Research and Improvement<br />Conclusion<br />References<br />3<br />
  7. 7. Abstract (i)<br />Web technology has become widely accepted application platform this days. It brings the remote and distributed application integration more successful. It brings parties together from distant places and helps making decisions more collaboratively and effectively. So, to have a reliable and well tested portal application Test Driven Design is obvious. <br />4<br />
  8. 8. Abstract (ii)<br />Application Test Driven Development or simply TDD is an evolutionary approach to produce well tested reliable and shippable code and thus improving the quality of the software through Fault avoidance and Fault detection at early stages and Fault recovery with simpler effort. In Test First Design or TFD approach, codes are being written to fail, executing tests and then updating the functional codes to pass. TDD is basically the combination of TFD and Refactoring.<br />5<br />
  9. 9. Introduction<br />This report is concentrated on Evaluating TDD in.NET environment. Web Application testing comprises of Functionality, Usability, Interface, Compatibility, Performance and Security which is a broad area from testing perspective. Not any of the available toolset performs testing for all the scenarios. So, we tried to narrow down some Web Testing Tools and concepts which contributed to the World Wide acceptance to .NET Applications.<br />6<br />
  10. 10. What is Quality?<br />Quality is a term that stands for wide variety of aspects for a particular product or environment. How well the environment is or how good the product is based on some specific criteria could be regarded as Quality. <br />According to Gerald Weinberg: “Quality is a Value to some person”<br />By Dr. Tom DeMarco “Product's quality is a function of how much it changes the world for the better”<br />Reliability, Scalability, Correctness, Completeness, Maintainability, Extensibility, Fault Tolerance etc. are the key selling points of Software Quality <br />http://ase.cpsc.ucalgary.ca/ase/uploads/SENG515615W2010/Lecture4_Agile_Engineering_Practices.pdf<br />7<br />
  11. 11. Quality Control Vs. Quality Assurance (i)<br />ISO 9001 Definition of<br />Quality Control<br /> The operational techniques and activities that are used to fulfill requirements for quality<br />Quality Assurance<br /> All those planned and systematic activities implemented to provide adequate confidence that an entity will fulfill requirements for quality<br />http://elsmar.com/pdf_files/QC%20vs%20QA.pdf<br />8<br />
  12. 12. Quality Control Vs. Quality Assurance (ii)<br /> QC Vs. QA<br />Product Process<br />Reactive Proactive<br />Line function Staff function<br />Find defects Prevent defects<br />Walkthrough Quality Audit<br />Testing Defining Process<br />Inspection Selection of tools<br />Checkpoint review Training<br />http://elsmar.com/pdf_files/QC%20vs%20QA.pdf<br />9<br />
  13. 13. Test Driven Development<br />The term TDD has been around since NASA’ s Project, Mercury in 1960s. But, when Kent Beck and Ward Cunningham introduced TDD as a eXtreme Programming (XP) practice, it started gaining popularity. <br /> So, What is TDD?<br />10<br />
  14. 14. What is Test Driven Development?<br />Ref: A Survey of Evidence for Test Driven Development in Academia, Chetan Desai, David Janzen, Kyle Savage Computer Science California Polytechnic State University San Luis Obispo, California USA {cdesai, djanzen}@calpoly.edu<br />11<br />
  15. 15. TDD – Industrial Case Studies@Microsoft<br />Two case studies were done at Microsoft to build empirical knowledge on the efficacy of TDD together with performing Cost-Benefit Economic Analysis on the utility of TDD:<br /><ul><li>Cost-benefit tradeoff between the increase in development time and
  16. 16. Resulting improvement in software quality</li></ul>Evaluating the Efficacy of Test-Driven Development: Industrial Case Studies, ThirumaleshBhat & NachiappanNagappan<br />12<br />
  17. 17. Windows networking team case study<br />Project A: Context Factor<br />Project A: Product Measure<br />Project A: Outcome<br />Evaluating the Efficacy of Test-Driven Development: Industrial Case Studies, ThirumaleshBhat & NachiappanNagappan<br />13<br />
  18. 18. MSN Team case study<br />Project B: Context Factor<br />Project B: Product Measure<br />Project B: Outcome<br />Evaluating the Efficacy of Test-Driven Development: Industrial Case Studies, ThirumaleshBhat & NachiappanNagappan<br />14<br />
  19. 19. Can someone write my Test?<br />15<br />
  20. 20. TDD Tools Used in this Research (i)<br />Testing Frameworks: <br /><ul><li>Visual Studio Team System Unit Testing Framework
  21. 21. MVC .NET Testing Framework
  22. 22. Microsoft PEX</li></ul>Unit Testing: <br /><ul><li>NUnit
  23. 23. MVC .NET with MOCK
  24. 24. MS Test for Visual Studio</li></ul>16<br />
  25. 25. TDD Tools Used in this Research (ii)<br />Database Testing: <br /><ul><li>DBUnit .NET
  26. 26. DB Pro</li></ul>Automated Web Testing<br /><ul><li>Selenium
  27. 27. Visual Studio Automated Web Test</li></ul>Load/Stress Testing<br /><ul><li>Visual Studio Web Test
  28. 28. WCat 6.3 (x86)</li></ul>17<br />
  29. 29. Database Testing using DBUnit/DB Pro<br />18<br />
  30. 30. 19<br />
  31. 31. What is Database Testing and Why? (i)<br />Database testing is a defined process to test database programmability objects. Now, the question comes: what are the database objects that requires testing to produce quality object? <br />A Database consists of the following programmability objects:<br /><ul><li>Stored Procedures
  32. 32. DB Functions
  33. 33. Triggers
  34. 34. Rules
  35. 35. DB Assemblies</li></ul>20<br />
  36. 36. What is Database Unit Testing and Why?(ii)<br />So, the database unit tests could be created before hand to test the database programmability objects and make sure that they produce the result as expected and existing functionality are working<br />The following types of database unit tests could be performed:<br /><ul><li>Schema Test
  37. 37. Feature/Functionality Test
  38. 38. Security Test
  39. 39. Stock data Test
  40. 40. Referential Integrity Constraints</li></ul>21<br />
  41. 41. What to Test?<br />Refactoring Databases: Evolutionary Database Design, by Scott W. Ambler and Pramod J. Sadalage, Addison Wesley Professional    ISBN#:  0-321-29353-3 http://www.ambysoft.com/books/refactoringDatabases.html<br />22<br />
  42. 42. Database Testing with DBUnit<br />DBUnit is a Open Source Database Testing Framework which was created by Manuel Laflamme<br />DBUnit is a Database Unit Testing Framework to Test Database Driven Classes, Procedures or Functions. <br />NUnit, MVC .NET/Visual Studio Testing platforms can be used to build a standard test suite<br />Following Operations can be performed using DBUnit<br />UPDATE TRUNCATE <br />INSERT REFRESH<br />DELETE CLEAN_INSERT<br />DELETE_ALL NONE<br />Other Operations<br />Composite Operation<br />Transaction Operation<br />Identity Insert Operation<br />23<br />
  43. 43. DBUnit Supported Databases<br />Ref: http://dbunit.wikidot.com/supportedrdbms<br />24<br />
  44. 44. Creating a DBUnit Test Class<br />Create a XML Dataset or Export Data from Databases<br />25<br />If the DBUnit Test Class Name is DbUnitTestCase then the Data Set name has to be DbUnitTestCaseDataset.xml and has to be in the same folder<br />Flat XML:<br /><?xml version="1.0" encoding="utf-8" ?><br /><dataset><br /> <table_name col1="value" /><br /></dataset><br />
  45. 45. Create a Test Class and Extend DBTestCase<br />using System;<br />using System.Data;<br />using System.Data.Sql;<br />using System.Data.SqlClient;<br />using System.Collections.Generic;<br />using System.Reflection;<br />using System.Xml;<br />using DbUnit.Framework;<br />using DbUnit.Core;<br />using DbUnit.Dataset;<br />using NUnit.Framework;<br />using NMock2;<br />namespace MyDBUnitProject<br />{<br /> [TestFixture]<br /> public class MyDBUnitTestCase2 : DbUnitTestCase<br /> {<br /> private SqlConnection connection = null;<br /> Mockery mocks;<br /> private IDataSet dataset;<br />26<br />
  46. 46. Implement SetUp and TearDown<br /> [SetUp]<br /> public void SetUpTestCase()<br /> {<br /> mocks = new Mockery();<br /> dataset = new EmbeddedFlatXmlDataSet(this.GetType());<br /> connection = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=BIteDB;Data Source=localhostsqlexpress");<br />connection.Open();<br /> }<br /> [TearDown]<br /> public void TearDownTestCase()<br /> {<br />connection.Close(); ;<br /> }<br />27<br />
  47. 47. Implement Test Method<br /> [Test]<br /> public void TestQuerySQLMessage()<br /> {<br /> string _sql = "SELECT AttachmentLink as ReturnValue from Message WHERE CAST(MsgContent AS varchar(4000)) ='My Test'";<br />SqlCommand _cmd = new SqlCommand(_sql, connection);<br />SqlDataReader _reader = _cmd.ExecuteReader();<br /> string _AttachmentLink = "";<br /> while (_reader.Read())<br /> {<br /> _AttachmentLink = _reader["ReturnValue"].ToString();<br /> }<br />Assert.AreNotEqual("", _AttachmentLink);<br /> }<br />[Test]<br /> public void TableNameSetCorrectly()<br /> {<br />Assert.AreEqual("table_name", dataset.Tables[0].Name);<br /> }<br />28<br />
  48. 48. Nunit/DBUnit Test Results<br />29<br />
  49. 49. DBUnit Benefits<br />DBUnit provides a stable framework to create and adopt Database Test cases with minimal effort<br />It can manage the state of database through the test’s life cycle<br />At the end of testing the database can be placed back into its pre-test state<br />A database can be populated with a desired data set before a test<br />DBUnit test can easily automated by controlling major dependencies<br />DBUnit test can be performed utilizing most types of database objects (Tables, Views, Stored Procedures)<br />DBUnit Tests do not require manual intervention between tests<br />DBUnit Test results doesn’t need manual interpretation<br />Code stability increases in a Team environment<br />Easy to Learn and Implement<br />Wide range of support for standard databases<br />DBUnit documentation is pretty well defined<br />DBUnit tests are easily manageable<br />It is easier to generate the seed data using the dump feature<br />30<br />
  50. 50. DBUnit Limitations<br />Primary test data is XML but it is also possible to create test cases for standard databases <br />Test Data generation plan is absent and so have to create and refresh the test dataset when Actual schema changes and so the seed and resulted data could be different<br />Primary support for XML Dataset is Flat XML and need to have all columns defined in the first row<br />DBUnit does not support multiple Resultset<br />31<br />
  51. 51. DBUnit – Short Demo<br />32<br />
  52. 52. Database Testing with MS DB Pro<br />The desire on the part of the database developer to use familiar T-SQL scripts to express the unit-test logic and the desire to take advantage of powerful Microsoft® .NET Framework-targeted languages<br />Encapsulating the test in T-SQL code and then hosting the T-SQL in C# or Visual Basic .NET code. The unit-test designer generates both, enabling either (or both) to be modified to meet individual needs.<br />Database unit testing with Team System provides or supports the features for entire framework and using proper context [Authentication and Security Aspects etc.]<br />Apply Test-Driven Development to your Database Projects - Jamie Laflen<br />http://msdn.microsoft.com/en-us/magazine/cc164243.aspx#S2<br />33<br />
  53. 53. Two sample joined tables<br />34<br />
  54. 54. Stored Preocedure<br />CREATE PROCEDURE [dbo].[uspGetEmployeeManagers]<br /> @EmployeeID [int]<br />AS<br />BEGIN<br /> SET NOCOUNT ON;<br /> -- Use recursive query to list out all Employees required for a particular Manager<br /> WITH [EMP_cte]([EmployeeID], [ManagerID], [FirstName], [LastName], [Title], [RecursionLevel]) -- CTE name and columns<br /> AS (<br /> SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], e.[Title], 0 -- Get the initial Employee<br /> FROM [HumanResources].[Employee] e <br /> INNER JOIN [Person].[Contact] c <br /> ON e.[ContactID] = c.[ContactID]<br /> WHERE e.[EmployeeID] = @EmployeeID<br /> UNION ALL<br /> SELECT e.[EmployeeID], e.[ManagerID], c.[FirstName], c.[LastName], e.[Title], [RecursionLevel] + 1 -- Join recursive member to anchor<br /> FROM [HumanResources].[Employee] e <br /> INNER JOIN [EMP_cte]<br /> ON e.[EmployeeID] = [EMP_cte].[ManagerID]<br /> INNER JOIN [Person].[Contact] c <br /> ON e.[ContactID] = c.[ContactID]<br /> )<br /> -- Join back to Employee to return the manager name <br /> SELECT [EMP_cte].[RecursionLevel], [EMP_cte].[EmployeeID], [EMP_cte].[FirstName], [EMP_cte].[LastName], <br /> [EMP_cte].[ManagerID], c.[FirstName] AS 'ManagerFirstName', c.[LastName] AS 'ManagerLastName' -- Outer select from the CTE<br /> FROM [EMP_cte] <br /> INNER JOIN [HumanResources].[Employee] e <br /> ON [EMP_cte].[ManagerID] = e.[EmployeeID]<br /> INNER JOIN [Person].[Contact] c <br /> ON e.[ContactID] = c.[ContactID]<br /> ORDER BY [RecursionLevel], [ManagerID], [EmployeeID]<br /> OPTION (MAXRECURSION 25) <br />END;<br />35<br />
  55. 55. DB Pro Test Results<br />36<br />
  56. 56. Adding a Data Generation Plan<br />37<br />
  57. 57. Selecting Tables for Test Data<br />38<br />
  58. 58. Data Column Configuration<br />39<br />
  59. 59. Generate Test Data before Unit Test<br />40<br />
  60. 60. DB Pro Benfits<br />Feature Tests, Schema Tests, Security Tests, Stock-Data Tests can be performed using DB Pro<br />Automatic generation of SQL script stubs of unit tests for stored procedures, functions, and triggers<br />DB Pro Provides a set of built-in test conditions to verify results including the rows returned, scalar values, and execution time<br />Automatic Generation of Test Data using Data Generation Tool<br />It sets the database state through it’s data generation feature<br />Same Test Data can be generated repeatedly based on seed value<br />Pre-Test, Test and Post Test results could be written, executed and evaluated<br />41<br />
  61. 61. DB Pro Limitations<br />Only supported database is MS SQL Server<br />Need Visual Studio Team System - Database Edition to get the DB Pro Test Suite<br />Supports C#/VB platforms for unit testing<br />Data generation tool needed to use to generate test data and so database sandbox concept is not in there so that may have to work on real data and could be rolled back the data after testing<br />42<br />
  62. 62. DB Pro – Short Demo<br />43<br />
  63. 63. Web UI Testing using Selenium/Web Test<br />44<br />
  64. 64. Selenium for Web UI Testing<br />Selenium is an automated web user interface testing tools that provides the environment to write a test case in respective platform [here .NET]. It has two components:<br /><ul><li>Server: A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests
  65. 65. Client: Client libraries to Build a Test Case Using NUnit and Mock</li></ul>45<br />
  66. 66. Selenium RC (Remote Control)<br />http://seleniumhq.org/projects/remote-control/<br />46<br />
  67. 67. Selenium Feature Matrix<br />Ref: http://wiki.openqa.org/pages/viewpage.action?pageId=763<br />47<br />
  68. 68. Start with Selenium Project in .NET<br />Download Selenium from <br />Download and Install NUnit or Any other testing suite<br />Create a Visual Studio Test Project <br />Reference the following DLLs: nmock.dll, nunit.core.dll, nunit. framework.dll, ThoughtWorks.Selenium.Core.dll, ThoughtWorks.Selenium. IntegrationTests.dll and ThoughtWorks.Selenium.UnitTests.dll<br />Write a Selenium Test Case<br />48<br />
  69. 69. Selenium Test Class<br />namespace MySeleniumTest<br />{<br /> [TestFixture]<br /> public class MySeleniumTest1<br /> {<br /> private ISelenium selenium;<br /> private StringBuilderverificationErrors;<br /> [SetUp]<br /> public void SetupTest()<br /> {<br /> selenium = new DefaultSelenium("localhost", 2613, "*firefox",<br /> "http://localhost:2613");<br />selenium.Start();<br />verificationErrors = new StringBuilder();<br /> }<br /> [TearDown]<br /> public void TeardownTest()<br /> {<br /> try<br /> {<br />selenium.Stop();<br /> }<br /> catch (Exception)<br /> {<br /> // Ignore errors if unable to close the browser <br /> }<br />Assert.AreEqual("", verificationErrors.ToString());<br /> }<br /> [Test]<br /> public void TheNewTest()<br /> {<br />selenium.Open("/Home/");<br />selenium.Click("link=About");<br />selenium.WaitForPageToLoad("30000");<br /> }<br /> }<br />}<br />49<br />
  70. 70. Selenium Benefits<br />Selenium could be used for the functional, regression, load testing of the web based applications. The automation tool could be implemented for post release validation with continuous integration tools like Hudson or CruiseControl.<br />C#, Java, Perl, PHP, Python, Ruby are being supported as the programming/testing platform<br />Selenium allows simple and powerful Document Object Level (DOM) level testing <br />It supports traditional waterfall or Agile environments<br />Selenium is a pretty good tool for continuous integration<br />Selenium support AJAX<br />50<br />
  71. 71. Selenium Limitations<br />Setting up Selenium Test Suite is complex and step by step documentation is hard to find<br />Only supports web application though it has functional, regression, load testing features<br />Diagnostics process is cumbersome<br />In AJAX implementations, it doesn’t know when AJAX process is completed<br />51<br />
  72. 72. Selenium – Short Demo<br />52<br />
  73. 73. Visual Studio Web Test for UI Testing<br />The main purpose of Web UI testing is to uncover functional problems of a Web Application. But, there are some key challenges for Web UI Testing:<br /><ul><li>Different Browser/Client Environment
  74. 74. Client Side Scripting/Security Settings/Validation
  75. 75. Session Variables and Timeouts</li></ul>53<br />
  76. 76. How it works?<br />The test harness system consists of three files (ASP .NET Page, Left.Html and Main.Html)<br />ASP .NET Page is loaded into an HTML frame<br />Left.Html which contains the test automation JScript code is loaded into another HTML frame<br />Main.Html container for the two frames and holds a global variable called timesAppLoaded which tracks how many times the Web application under test has been loaded into its test frame<br />Test scenario script uses the timesAppLoaded value to determine exactly what actions to take on the Web app and then reloads the Web application<br />This Cycle continues until the system reaches a final state that you specify in the test script, and a pass or fail result is determined.<br />Ref: Lightweight UI Test Automation for ASP.NET Web Apps, James McCaffrey, http://msdn.microsoft.com/en-us/magazine/cc163814.aspx#S1<br />54<br />
  77. 77. Web Test Container – Main.Html<br /><html><br /> <head><br /> <script language="JScript"><br />vartimesAppLoaded = 0;<br />varscenarioID = "001";<br /> </script><br /> </head><br /> <frameset cols="40%,*"><br /> <frame src="left.html" name="left"><br /> <frame src="color.aspx" name="right" onload="left.updateState();"><br /> </frameset><br /></html><br />55<br />
  78. 78. Visual Studio Web Test<br />56<br />
  79. 79. Adding Validation Rule<br />57<br />
  80. 80. Visual Studio Web Test Results<br />58<br />
  81. 81. Visual Studio Web UI Test Benefits<br />Creation of Test Cases for Multiple Browser Support and browsers cross-compatibility can be tested using this tool<br />Use different session/data variables for the same test and uncover different feature set according to selected criteria/setting. Let’s say use Admin and Regular user logins<br />Support for AJAX/Silverlight<br />May call and test other test cases(for an example DBUnit/Nunit )<br />Convert Step to Code option allows testers to capture the outline of the test and dig into the code<br />59<br />
  82. 82. Visual Studio Web UI Test Limitations<br />Need Visual Studio Team System to get the Web UI Testing Platform<br />Supports C#/VB platforms for unit testing<br />Web UI Test is designed for .NET platform<br />60<br />
  83. 83. MS Web Test – Short Demo<br />61<br />
  84. 84. Microsoft MVC .NET Test Suite<br />62<br />
  85. 85. Web Application Testing<br />Web portal applications are being developed using MVC pattern paradigm. MVC stands for Model-View-Controller where :<br /><ul><li>Front End Application logics are being hosted in the “View” component
  86. 86. All Business Logics are being hosted in “Model” component
  87. 87. And Managed by “Controller” component</li></ul>63<br />
  88. 88. MVC Pattern<br />http://msdn.microsoft.com/en-us/library/ms978748.aspx<br />64<br />
  89. 89. Web Portal Testing Constraints<br />Testing results may vary from Dev, Test and Production environment<br />Testing results may vary for users with different security settings or grants<br />Blackbox testing is challenging as less control on the environment and html parsing is slow<br />Applying TDD is difficult in web applications as the test cases are written to fail and then write the test case to pass followed by refactoring. So, needs a web portal mock up to test small changes time and again <br />65<br />
  90. 90. MVC Project Layers<br />Abstract Layer<br />Business Layer<br />Data Layer<br />MVC project <br />66<br />
  91. 91. ASP .NET Framework<br />Modules<br />Globalization<br />Caching<br />Controls<br />Master Pages<br />Pages<br />Roles<br />Profile<br />Membership<br />Handlers<br />Intrinsics<br />Etc.<br />67<br />
  92. 92. ASP .NET MVC Framework<br />ASP.NET<br />Dynamic Data<br />Presentation<br />ASP.NET<br />WebForms<br />ASP.NET<br />MVC<br />ASP.NET<br />Core<br />Runtime<br />http://www.asp.net/(S(d35rmemuuono1wvm1gsp2n45))/mvc/<br />68<br />
  93. 93. ASP.NET MVC Features (i)<br />Separation of application tasks (input logic, business logic, and UI logic), testability, and test-driven development (TDD) by default<br />All core contracts in the MVC framework are interface-based and can be tested by using mock objects, which are simulated objects that imitate the behavior of actual objects in the application<br />Unit-test applications without having to run the controllers in an ASP.NET process, which makes unit testing fast and flexible<br />Any unit-testing framework can be utilized that is compatible with the .NET Framework. <br />69<br />
  94. 94. ASP.NET MVC Features (ii)<br />An extensible and pluggable framework<br />ASP.NET MVC framework components are easily customizable<br />The ASP.NET MVC framework also supports the use of Dependency Injection (DI) and Inversion of Control (IOC) container models. DI allows you to inject objects into a class, instead of relying on the class to create the object itself<br />Support for existing ASP.NET features. ASP.NET MVC lets you use features such as forms authentication and Windows authentication, URL authorization, membership and roles, output and data caching, session and profile state management, health monitoring, the configuration system, and the provider architecture. <br />70<br />
  95. 95. Creating .NET Web App<br />71<br />
  96. 96. Creating a Unit Test Project<br />72<br />
  97. 97. Model-View-Controller (MVC)<br />73<br />
  98. 98. MVC Top Level Directories<br />74<br />
  99. 99. Typical MVC .NET Project Structure<br />75<br />
  100. 100. Change Password Method<br /> [Authorize]<br /> [HttpPost]<br /> public ActionResultChangePassword(ChangePasswordModel model)<br /> {<br /> if (ModelState.IsValid)<br /> {<br /> if (MembershipService.ChangePassword(User.Identity.Name, model.OldPassword, model.NewPassword))<br /> {<br /> return RedirectToAction("ChangePasswordSuccess");<br /> }<br /> else<br /> {<br />ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");<br /> }<br /> }<br /> // If we got this far, something failed, redisplay form<br /> return View(model);<br /> }<br />76<br />
  101. 101. Change Password Test Method<br /> [TestMethod]<br /> public void ChangePassword_Post_ReturnsRedirectOnSuccess()<br /> {<br /> // Arrange<br />AccountController controller = GetAccountController();<br />ChangePasswordModel model = new ChangePasswordModel()<br /> {<br />OldPassword = "goodOldPassword",<br />NewPassword = "goodNewPassword",<br />ConfirmPassword = "goodNewPassword"<br /> };<br /> // Act<br />ActionResult result = controller.ChangePassword(model);<br /> // Assert<br />Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));<br />RedirectToRouteResultredirectResult = (RedirectToRouteResult)result;<br />Assert.AreEqual("ChangePasswordSuccess", redirectResult.RouteValues["action"]);<br /> }<br />77<br />
  102. 102. Right Click and Create Test Method<br />78<br />
  103. 103. Membership Service Mocking<br /> private class MockMembershipService : IMembershipService<br /> {<br /> public intMinPasswordLength<br /> {<br /> get { return 10; }<br /> }<br /> public boolValidateUser(string userName, string password)<br /> {<br /> return (userName == "someUser" && password == "goodPassword");<br /> }<br /> public MembershipCreateStatusCreateUser(string userName, string password, string email)<br /> {<br /> if (userName == "duplicateUser")<br /> {<br /> return MembershipCreateStatus.DuplicateUserName;<br /> }<br /> // verify that values are what we expected<br />Assert.AreEqual("goodPassword", password);<br />Assert.AreEqual("goodEmail", email);<br /> return MembershipCreateStatus.Success;<br /> }<br /> public boolChangePassword(string userName, string oldPassword, string newPassword)<br /> {<br /> return (userName == "someUser" && oldPassword == "goodOldPassword" && newPassword == "goodNewPassword");<br /> }<br /> }<br />79<br />
  104. 104. Unit Test Results in .NET 3.5<br />80<br />
  105. 105. ASP.NET MVC Benefits<br />Resolving complexity by dividing an application into the model, the view, and the controller<br />No view state or server-based forms. So, provides full control over the behavior of an application<br />Front Controller pattern processes Web application requests through a single controller<br />Creating application that supports a rich routing infrastructure<br />Provides better support for test-driven development (TDD)<br />Fits into large teams of Developers and Web designers who need a high degree of control over the application behavior. <br />81<br />
  106. 106. ASP.NET MVC Limitations<br />Doesn’t use event model to preserve state over HTTP<br />Doesn’t use view state or server-based forms and so hard to manage states<br />Doesn’t fit well for small teams to implement RAD<br />Complex design for application development, because the components (the Page class, controls, and so on) are tightly integrated and usually require more code than the Traditional Web Application model<br />82<br />
  107. 107. MVC .Net – Short Demo<br />83<br />
  108. 108. Parameterized Unit Testing (PUT) and Microsoft Pex<br />84<br />
  109. 109. Unit Testing At a Glance<br />Three sections of Unit Tests:<br /><ul><li>Data
  110. 110. Method Sequence
  111. 111. Assertions</li></ul>void Add() {<br />int item = 3;<br />var list = new List();<br />list.Add(item); <br />var count = list.Count;<br />Assert.AreEqual(1, count);<br />}<br />Ref : Parameterized Unit Testing: Principles, Techniques, and Applications in Practice, Nikolai Tillmann, Peli de Halleux, Wolfram Schulte (Microsoft Research) Tao Xie (North Carolina State University)http://research.microsoft.com/en-us/projects/pex/pexpublictutorialslides.pptx<br />85<br />
  112. 112. Incomplete Test Coverage with Fixed Data<br />list.Add(3); <br /><ul><li>Bad data may result in redundant, or worse, incomplete test suites.
  113. 113. Fixed data values become invalid when product changes
  114. 114. Why choose a value which may not make sense?</li></ul>Ref : Parameterized Unit Testing: Principles, Techniques, and Applications in Practice, Nikolai Tillmann, Peli de Halleux, Wolfram Schulte (Microsoft Research) Tao Xie (North Carolina State University)http://research.microsoft.com/en-us/projects/pex/pexpublictutorialslides.pptx<br />86<br />
  115. 115. What is Parameterized Unit Test?<br />Parameterized Unit Test is a Unit Test with Parameters<br />Separation of concerns<br />Data is generated by a tool<br />Developer can focus on functional specification<br />void Add(List list, int item) {<br />var count = list.Count;<br />list.Add(item);<br />Assert.AreEqual(count + 1, list.Count);<br />}<br />Ref : Parameterized Unit Testing: Principles, Techniques, and Applications in Practice, Nikolai Tillmann, Peli de Halleux, Wolfram Schulte (Microsoft Research) Tao Xie (North Carolina State University)http://research.microsoft.com/en-us/projects/pex/pexpublictutorialslides.pptx<br />87<br />
  116. 116. PUT Sample<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />88<br />
  117. 117. Parameterized Unit Testing (PUT)<br />Some popular unit testing tools, like Junit, Nunit doesn’t support the automation of creating unit tests<br />In some cases it even takes more lines of code to create the unit tests than more implementation being tested<br />Some Automatic test generation tools may not even track the divide-by-zero type errors rather than specific error message<br />PUT or Parameterized Unit Test accepts behavioral parameters/argument sets for a specific test method <br />Ref: Automating Software Testing Using Program Analysis, Patrice Godefroid, Peli de Halleux, Aditya V. Nori, Sriram K. Rajamani, Wolfram Schulte, and Nikolai Tillmann, Microsoft Research Michael Y. Levin, Microsoft Center for Software Excellence<br />89<br />
  118. 118. PUT Contributions<br />They allow unit tests to play a greater role as specifications of program behavior. In fact, PUTs are axiomatic specifications.<br />They enable automatic case analysis, which avoids writing implementation-specific unit tests.<br />Their generated test cases often result in complete path coverage of the implementation, which amounts to a formal proof of the PUT’s assertions.<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />90<br />
  119. 119. PUT Framework<br />Symbolic State<br />Constraints<br />Symbolic Evaluation<br />Axioms<br />Test Case generation<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />91<br />
  120. 120. Symbolic State<br />Its is basically the state of program execution. It can contain expressions with symbolic variables.<br />Symbolic expressions: <br />E = | o object ids, infinite set of potential object identifiers<br />| v variables, set of symbolic variable identifiers<br />| t types, set of type identifiers<br />| f(E bar) function application, set of function symbols<br />| For All (v bar).E universal quantification, <br />where x to denote lists of items x1, . . . , xn.<br />Function symbols: equals(x, y) denotes whether x and y represent the same value for value Types, type(x) denotes the runtime type of object x, and len(x) the length of array x<br />Heaps:No of Times a method being called in a nested method call<br />Symbolic state: A symbolic state is a 5-tuple S = (O, A, He,Hi, X), where the current set of objects O is a subset of ObjectId, the program stack A is a stack of activation records, He and Hi are expressions denoting the extensional heap and the intentional heap respectively, and finally, X, an object expression, denotes the current exception. Say: O(S) is being written for projection on S<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />92<br />
  121. 121. Symbolic Evaluation<br />Symbolic Evaluation describes the effect of the current instruction from a given constrained state (S,C).<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />93<br />
  122. 122. Axioms<br />Axiom is basically of summary of external behavior<br />[TestAxiom]<br />public void TestQuickSort(int[] a)<br /> {<br />Assume.IsTrue(a != null); <br />QuickSort.Sort(a, 0, a.Length - 1);<br /> for (int i = 0; i < a.Length - 1; i++)<br />Assert.IsTrue(a[i] <= a[i + 1]);<br /> }<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />94<br />
  123. 123. Test Case Generation<br />Each transition sequence (S0,C0) ! (S1,C1) ! · · · represents a unique execution path of the program. <br />[TestMethod]<br />public void TestQuickSort597()<br />{<br />int[] ints = new int[2];<br />ints[1] = 1;<br />this.TestQuickSort(ints);<br />} <br />[TestMethod]<br />public void TestQuickSort512()<br />{<br />int[] ints = new int[3];<br />ints[0] = -2147475453;<br />ints[1] = 1073750016;<br />ints[2] = 8194;<br />this.TestQuickSort(ints);<br />}<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />95<br />
  124. 124. Constraints<br />A constraint on a symbolic state is a pair C = (BG, PC), where BG is the static background, which only depends on the program declarations, and PC is the dynamic path condition, which is built up during symbolic evaluation<br />Ref: Parameterized Unit Tests, Nikolai Tillmann (nikolait@microsoft.com), Wolfram Schulte (schulte@microsoft.com), Microsoft Research<br />One Microsoft Way, Redmond WA USA<br />96<br />
  125. 125. What is Pex?<br />Pex stands for Program Exploration which is a white box test generation tool developed at Microsoft Research that helps developers to write PUTs in .NET platform and thus generate automated test cases<br />For each PUT, Pex uses dynamic test-generation techniques to compute a set of input values that exercise all the statements and assertions in the analyzed program which eventually cover all reachable branches<br />Ref: Automating Software Testing Using Program Analysis, Patrice Godefroid, Peli de Halleux, Aditya V. Nori, Sriram K. Rajamani, Wolfram Schulte, and Nikolai Tillmann, Microsoft Research Michael Y. Levin, Microsoft Center for Software Excellence<br />97<br />
  126. 126. Pex Sample Project<br />98<br />
  127. 127. Sample Web Method to Test [ServicePoints.asmx]<br />99<br />
  128. 128. Pex Test Case: Test Axiom [ServicePointsTest.cs]<br />100<br />
  129. 129. Pex Test Method 1: Null Validation<br />101<br />
  130. 130. Pex Test Method 2: Validation with valid string value<br />102<br />
  131. 131. NUnit Test Case<br /> [TestFixture]<br /> public class UserTest<br /> {<br /> User _user;<br /> [SetUp]<br /> public void Setup()<br /> {<br /> _user = new User();<br /> }<br /> [Test]<br /> public void EmailTest()<br /> {<br /> _user.Email = “fazlul@telus.net";<br />Assert.AreEqual(“fazlul@telus.net", _user.Email);<br /> }<br /> [Test]<br /> public void IsValidTestWhenPasswordsMismatch()<br /> {<br /> _user.Password = “SENG";<br /> _user.Password = “CPSC";<br />Assert.IsFalse(_user.IsValid());<br /> }<br /> [Test]<br /> public void IsValidTestWhenPasswordsMatch()<br /> {<br /> _user.FirstName = “Fazlul";<br /> _user.LastName = “Chowdhury";<br /> _user.Email = "fazlul@telus.net ";<br /> _user.Password = " SENG ";<br /> _user.PasswordConfirmation = " SENG ";<br />Assert.IsTrue(_user.IsValid());<br /> }<br /> [Test]<br /> public void UserNameTest()<br /> {<br /> _user.Email = "fazlul@telus.net ";<br />Assert.AreEqual(" fazlul@telus.net ", _user.UserName);<br /> _user.UserName = "fazlul@telus.net ";<br />Assert.AreEqual("fazlul@telus.net ", _user.Email);<br /> }<br /> }<br />103<br />
  132. 132. Instantiating PUT in PEX<br /> [PexMethod]<br /> public string ConvertToUpper([PexAssumeUnderTest]MyPexTest1Class target, string Input)<br /> {<br /> string result = target.ConvertToUpper(Input);<br /> return result;<br /> }<br /> [PexMethod]<br /> public void ConvertToUpperAgain(string Input)<br /> {<br /> MyPexTest1Class MyP = new MyPexTest1Class();<br />var First = MyP.ConvertToUpper(Input);<br />var Second = MyP.ConvertToUpper(First);<br />Assert.AreEqual(First, Second);<br /> }<br />104<br />
  133. 133. PUT & PEX benefits<br />PUT specifies the external behavior of the methods for all test arguments and so the tests cover all possible test environment and constraints<br />PUTs can be instantiated to re-obtain traditional closed unit tests and to re-verify the result of tests<br />PUT enables automatic case analysis, which avoids writing implementation-specific unit tests<br />Using PUT in PEX, it is fairly simple to auto generate test cases and cover all possible testing scenarios, constraints and values<br />105<br />
  134. 134. PUT & PEX limitations<br />PEX works for deterministic model of test methods and goes in cycle for non deterministic methods until hits exploration bounds<br />PEX doesn’t work in Multi-Thread model<br />PEX can analyze any .NET language but the code generation only supports C#<br />PEX uses an automatic constraint solver to determine which values are relevant for the test and the code-under-test but which is also limited [Say: floating point arithmetic cannot be reasoned precisely]<br />Lack of Tests for Oracle<br />Advanced Concepts : PUT in PEX, http://research.microsoft.com/en-us/projects/pex/pexconcepts.pdf <br />106<br />
  135. 135. Microsoft Pex – Short Demo<br />107<br />
  136. 136. Load Testing<br />108<br />
  137. 137. Load Testing on Web Applications<br />To perform a load test on a web application we need to:<br /><ul><li>Identify the performance-critical scenarios
  138. 138. Identify the workload profile for distributing the entire load among the key scenarios
  139. 139. Identify the metrics that we want to collect in order to verify them against your performance objectives.
  140. 140. Design tests to simulate the load
  141. 141. Use tools to implement the load according to the designed tests, and capture the metrics
  142. 142. Analyze the metric data captured during the test</li></ul>By using an iterative testing process, these steps should help us achieve our performance objectives<br />Performance Testing Guidance for Web Applications, J.D. Meier, Carlos Farre, PrashantBansode, Scott Barber, and Dennis Rea<br />http://msdn.microsoft.com/en-us/library/bb924372.aspx<br />109<br />
  143. 143. Visual Studio Load Testing<br />110<br />
  144. 144. Visual Studio Load Testing Results<br />111<br />
  145. 145. VS Load Test – Short Demo<br />112<br />
  146. 146. Advantages of TDD centric Web Applications design<br />Code will be separated from the Data layer<br />Easy to understand and code transfer<br />It increases the system performance<br />Easy to maintain documentation<br />113<br />
  147. 147. Conclusion (i)<br />This research was done to investigate numerous testing tools in .NET platform. We found that various testing tools are specialized in specific testing contexts. NUnit/Visual Studio Testing Tools/MVC .NET and Microsoft PEX are built for unit testing where as DBUnit/DB Pro are specialized in Database Testing, Selenium and MS Web test are for Web UI Testing and VS Load Test and Wcat are being used for Load/Stress testing. But, Microsoft Team System Developer edition comes with a full blown test suite of which VS Test is for Unit Testing, DB pro is for database testing, Web Test for web UI testing and VS Load Test is for Load testing. External testing tools like DBUnit and Nunit test cases can also be generated from Visual Studio Testing suite. MVC .NET implements the Model, View and Controller pattern which makes TDD easier for a Web Application. MVC resolves the Server based forms which were difficult to test. MVC framework fits into large teams of Developers and Web designers who need a high degree of control over the application behavior. <br />114<br />
  148. 148. Conclusion (ii)<br />This presentation also highlighted the concept of Parameterized Unit Tests or simply PUT which is basically a generalization of established closed unit tests. Parameterized Unit Test or PUT has been implemented in Microsoft PEX to generate automated Unit tests. Behavioral parameters can be injected into PUT to cover a particular implementation. State Change, Return Values and Exceptional return values states the Method's behavior. Detailed demonstration of PEX covered the Axiomatic approach of Test Methods and it’s test coverage scenario together with automated and regression test generation.<br />115<br />
  149. 149. References<br />Evaluating Current Testing Processes of Web-Portal Applications <br /> Link: http://ase.cpsc.ucalgary.ca/ase/uploads/Publications/bajwaMaurerXiong2005a.pdf<br />Multiple Perspectives on Executable Acceptance Test-Driven Development<br /> Link: http://ase.cpsc.ucalgary.ca/ase/uploads/Publications/XP2007_Melnik_Maurer.pdf<br />http://ase.cpsc.ucalgary.ca/ase/uploads/SENG515615W2010/Lecture4_Agile_Engineering_Practices.pdf<br />http://elsmar.com/pdf_files/QC%20vs%20QA.pdf<br />http://dotnetslackers.com/articles/aspnet/ASPNETMVCFrameworkPart2.aspx<br />http://www.asp.net/learn/mvc<br />http://www.asp.net/(S(pdfrohu0ajmwt445fanvj2r3))/learn/mvc/tutorial-01-cs.aspx<br />http://ase.cpsc.ucalgary.ca/ase/uploads/Publications/XiongMaurerBajwa2005b.pdf<br />Building Web Apps without Web Forms, Link: http://msdn.microsoft.com/en-us/magazine/cc337884.aspx<br />MVC architecture in ASP. Net using C# and Microsoft Data Access Application block By  MunirShaikh February 28, 2006 , Link: http://www.c-sharpcorner.com/UploadFile/munnamax/mvcarchitecture02262006091052AM/mvcarchitecture.aspx<br />http://www.agiledata.org/essays/tdd.html<br />http://msdn.microsoft.com/en-us/library/ms978748.aspx<br />http://onjava.com/pub/a/onjava/2004/01/21/dbunit.html<br />http://msdn.microsoft.com/en-us/library/bb381703(VS.80).aspx<br />Good and Practical Ideas for Testers ,http://www.tassq.org/quarterly/docs/tassq_magazine-0609.pdf<br />Low-Level Web App UI Test Automation, James McCaffrey http://msdn.microsoft.com/en-us/magazine/cc163723.aspx<br />Advanced Concepts : PUT in PEX, http://research.microsoft.com/en-us/projects/pex/pexconcepts.pdf <br />116<br />
  150. 150. Thank You<br />117<br />

×