http://netponto.org<br />1ª Reunião em Coimbra - 09/04/2011<br />Testes? Mas isso não aumenta o tempo de projecto? Não que...
Patrocinadores desta reunião<br />
Pedro Rosa<br />LinkedIn<br />http://pt.linkedin.com/in/pedrobarraurosa<br />Twitter<br />http://twitter.com/pedrorosa<br />
Agenda<br />Why?<br />Code Coverage<br />Static / Dynamic Analysis<br />Unit Testing<br />WebTesting<br />Load (Performanc...
Também disponível em vídeo...<br />Assista!<br />http://www.vimeo.com/22446417<br />
The State of Application Development <br /><ul><li>Only 1 in 3 projects succeed
 Projects cost 50% more then budgeted
 Lack of software quality cost US 	businesses $59B / year.
 Bugs account for 55% of downtime </li></ul>Source:  Standish Group, 2006 Third Quarter Research Report, CHAOS Research Re...
Have you heard any of these?<br />“my testers are spending too long testing the same thing”<br />“tooling is expensive (ti...
68% <br />
What if you could…<br />reduce the time it takes to determine the root cause of a bug<br />enable users to easily run acce...
software bugs cost the US economy an estimated $59.5 billion every year<br />on average professional coders make 100 to 15...
Need something a little more concrete?<br />
USS Yorktown, SmartShip<br />crew member entered 0 in a data entry field, caused a “divide by 0” error that shut down prop...
Ariane 5 Flight 501<br />re-used code from ariane 4, but took a different flight path because of different booster design<...
F-22 Raptor<br />deploying overseas to japan the first time<br />crossed international dateline, computers crashed losing ...
Need something a little more visual?<br />
Still Not Convinced?<br />
Climbing<br />Cost of Failure<br />Conditioning<br />Training<br />Training Phase<br />
Release<br />Cost of Bugs<br />Test<br />Development<br />Software Phase<br />
Push Quality Upstream<br />Release<br />Cost of Bugs<br />Test<br />Development<br />Software Phase<br />
Where does testing happen?<br />70% of testing happens here<br />Majority of test tools target here<br />Black Box Testing...
Visual Studio 2010<br />
Test Manager 2010<br />UML Modeling<br />Manual Testing<br />Layer Diagram<br />Load Testing<br />Web Testing<br />Test Ca...
Visual Studio 2010 Test Types<br /><ul><li>Unit Test
 Database Unit Test
 Web PerformanceTest
 Load Test
 Manual Test (TestCase)
 Generic Test
 Ordered Test
Coded UI Test</li></li></ul><li>What is Unit Testing?<br />
Unit Test – Definition<br />A unit test is a piece of code written by a developer that exercises a very small, specific ar...
Manual Testing<br /><ul><li>You have already done unit testing
Manually, by hand
Manual tests are less efficient
Not structured
Not repeatable
Not on all your code
Not easy to do as it should be</li></li></ul><li>Unit Test  Example<br />int Sum(int[] array)<br />{<br />  sum = 0;<br />...
Unit Testing  Some Facts<br />Tests are specific pieces of code<br />Unit testing framework is needed<br />Visual Studio T...
Unit Testing – More Facts<br />All classes should be tested<br />Test anything that could have bugs<br />All methods shoul...
Why Unit Tests?<br />Unit tests dramatically decrease the number of defects in the code <br />Unit tests improve design <b...
Code and Test vs. Test Driven Development<br />
Unit Testing Approaches<br />"Code and Test" approach<br />Classical approach<br />"Test First" approach<br />Test driven ...
Code and Test Approach<br />Write code<br />Write unit test<br />Run and succeed<br />Time flow<br />
Create a testlist<br />Pick а test<br />Compile and fail<br />Write enough code to compile<br />Run test and fail<br />Wri...
Why Test Driven Development?<br />Helps find design issues early and avoids rework<br />Writing code to satisfy a test is ...
Unit Testing Frameworks and Visual Studio Team Test<br />
Unit Testing Frameworks<br />JUnit<br />The first popular unit testing framework<br />Based on Java<br />Similar framework...
Visual Studio Team Test – Features<br />Team Test (TT) is very well integrated with Visual Studio<br />Create test project...
Visual Studio Team Test –  Attributes<br />Test code is annotated using custom attributes<br /><ul><li>[TestClass]– denote...
[TestMethod]– denotes a unit test method
[ExpectedException]– test causes an exception
[Timeout]– sets a timeout for test execution
[Ignore]– temporary ignored test case
[ClassInitialize], [ClassCleanup]– setup / cleanup logic for the testing class
[TestInitialize], [TestCleanup]– setup / cleanup logic for each test case</li></li></ul><li>Assertions<br />Predicate is a...
VSTT – Assertions<br />Assertions check condition and throw exception if condition is not satisfied<br />Comparing values<...
VSTT – Assertions (2)<br />Checking for null value<br />IsNull(object [,message])<br />IsNotNull(object [,message])<br />C...
The 3A Pattern<br />Arrange all necessary preconditions and inputs<br />Act on the object or method under test<br />Assert...
VSTT – Example<br />public class Account<br />{<br />private decimal balance;<br />public void Deposit(decimal amount)<br ...
VSTT – Example (2)<br />using Microsoft.VisualStudio.TestTools.UnitTesting;<br />[TestClass]<br />public class AccountTest...
VSTT – Screenshot<br />
Visual Studio Team Test<br />Live Demo<br />
Unit Testing Best Practices<br />
Naming Standards for Unit Tests<br />The test name should express a specific requirement that is tested<br />Usually prefi...
Upcoming SlideShare
Loading in …5
×

Testes? Mas isso não aumenta o tempo de projecto? Não quero...

2,899 views
2,852 views

Published on

Os Testes são cada vez mais uma necessidade nos projectos de desenvolvimento de software... Sejam eles unitários, de carga ou de "User Interface", uma boa framework de testes ajuda a resolver os problemas mais cedo, de forma mais eficaz e mais barata.
No final da sessão vamos perceber não só para que servem, como são feitos e como o Visual Studio 2010 pode ajudar.

Published in: Technology
1 Comment
2 Likes
Statistics
Notes
No Downloads
Views
Total views
2,899
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
1
Likes
2
Embeds 0
No embeds

No notes for slide
  • These are some of the comments that we have heard from our customers. Are any of these being said by your testers?Broken down another way, can you answer these affirmatively?Do you know consistently when your software will ship?Are the defects created by your tester truly effective?No? &lt;click to next&gt;
  • All of the previous slides boils down to the fact that 68% of projects are challenged or FailNote that all of this is not due to testing, but good quality almost always ensures a successful release.According to Forrester Research, based on time, budget and delivering specified functionality 68% of projects never made it into production or were cancelled. The numbers tell the story with only 32% of projects being classified as successful with 44% being classed as challenged and 24% failed.The Standish Groups Extreme Chaos study tells a similar story with the average Cost overrun for projects being 45%, the average Time overrun at 63% and the average functionality delivered at 67%Considering that software development accounts for on average 25% of software spend for a company and is growing can organizations afford to continue to see these levels of failure? Identifying and addressing the root causes of software development failure makes business sense. Source: Extreme Chaos, The Standish Group International, Inc., 2000, 2004, 2006, 2009
  • Does this sound like a wish list? How much money is lost in the time that it takes to track down a bug?How much money is lost in the time it takes to isolate the differences between your development in test environments?
  • http://en.wikipedia.org/wiki/USS_Yorktown_(CG-48)#Smart_ship_testbed
  • http://en.wikipedia.org/wiki/Ariane_5_Flight_501
  • It is also important to understand where most testing happens in the spectrum of general testing to the more technical specialist testing.The Generalist Testers are usually professional testers with no coding background. Often these testers are experts in the business process or tool that is being developed. On the opposite side of the spectrum is the Specialist. This is a tester with strong coding skills.A fun side note: Microsoft’s testers are usually converted developers and tend to be on the specialist side of the graph.Black-box testing is a method of testing software that tests the functionality of an application as opposed to its internal structures or workings (see white-box testing). Specific knowledge of the application&apos;s code/internal structure and programming knowledge in general is not required. Test cases are built around specifications and requirements, i.e., what the application is supposed to do. It uses external descriptions of the software, including specifications, requirements, and design to derive test cases. These tests can be functional or non-functional, though usually functional. The test designer selects valid and invalid inputs and determines the correct output. There is no knowledge of the test object&apos;s internal structure.White-box testing (a.k.a. clear box testing, glass box testing, transparent box testing, or structural testing) is a method of testing software that tests internal structures or workings of an application as opposed to its functionality (black-box testing). An internal perspective of the system, as well as programming skills, are required and used to design test cases. The tester chooses inputs to exercise paths through the code and determine the appropriate outputs. It is analogous to testing nodes in a circuit, e.g. in-circuit testing (ICT). While white-box testing can be applied at the unit, integration and system levels of the software testing process, it is usually done at the unit level. It can test paths within a unit, paths between units during integration, and between subsystems during a system level test. Though this method of test design can uncover many errors or problems, it might not detect unimplemented parts of the specification or missing requirements. White-box test design techniques include: Control flow testing Data flow testing Branch testing Path testingAPI testing (application programming interface) – is a specific type of White Box testing of the application focusing on public and private APIs&lt;Question to Audience&gt;Looking at this spectrum, where does most testing happen today? &lt;collect answers and click&gt;Where do most testing tools target today? &lt;collect answers and click&gt;
  • This is the fully animated slide.
  • Let me drill down into the capabilities in each product. For a more extensive list of capabilities, please go to www.microsoft.com.vstudio.Microsoft Visual Studio 2010 Professional is the essential tool for basic development tasks to allow developers to implement their ideas easily. This includes core capabilities for Windows, Web, and Office development, along with new capabilities for Cloud and SharePoint development. There are also new tools for Silverlight and Multi-core development. With Visual Studio 2010 the IDE and editor were refreshed using Microsoft Windows Presentation Foundation.[CLICK]Microsoft Visual Studio 2010 Premium is a complete toolset for developers to deliver scalable, high quality applications. This includes support for offline database development, unit testing and change management, static code analysis, performance profiling and code coverage and code metrics. New capabilities including UI test automation (aka Coded UI Tests) and Test Impact Analysis are available in premium.[CLICK]Microsoft Visual Studio 2010 Ultimate is the comprehensive suite of application lifecycle management tools for teams to ensure quality results from design to deployment. This includes IntelliTrace – the new historical debugger which enables debugging events that ran previously on your machine, or another machine. Microsoft Test Manager 2010 is included in Ultimate enabling complete Test Case Management and test execution. Additionally the new architecture and modeling tools are included in Ultimate, including support for authoring UML diagrams (Activity, Use Case, Sequence, Component and Class diagrams are supported).[CLICK]
  • Testes? Mas isso não aumenta o tempo de projecto? Não quero...

    1. 1. http://netponto.org<br />1ª Reunião em Coimbra - 09/04/2011<br />Testes? Mas isso não aumenta o tempo de projecto? Não quero...Pedro Rosa<br />
    2. 2. Patrocinadores desta reunião<br />
    3. 3. Pedro Rosa<br />LinkedIn<br />http://pt.linkedin.com/in/pedrobarraurosa<br />Twitter<br />http://twitter.com/pedrorosa<br />
    4. 4. Agenda<br />Why?<br />Code Coverage<br />Static / Dynamic Analysis<br />Unit Testing<br />WebTesting<br />Load (Performance) Testing<br />
    5. 5. Também disponível em vídeo...<br />Assista!<br />http://www.vimeo.com/22446417<br />
    6. 6. The State of Application Development <br /><ul><li>Only 1 in 3 projects succeed
    7. 7. Projects cost 50% more then budgeted
    8. 8. Lack of software quality cost US businesses $59B / year.
    9. 9. Bugs account for 55% of downtime </li></ul>Source: Standish Group, 2006 Third Quarter Research Report, CHAOS Research Results<br />
    10. 10. Have you heard any of these?<br />“my testers are spending too long testing the same thing”<br />“tooling is expensive (time, licenses, people)”<br />“the developers say the defects are useless”<br />“when is my software ready to ship?”<br />“developers and testers work in silos and don’t communicate/speak the same language”<br />“we have a changed requirement, what do I need to test?”<br />
    11. 11. 68% <br />
    12. 12. What if you could…<br />reduce the time it takes to determine the root cause of a bug<br />enable users to easily run acceptance tests and track their results<br />reduce the time it takes to configure and manage test environments<br />reduce the time it takes to verify the status of a reported bug fix<br />repair a bug without having to reproduce it<br />
    13. 13. software bugs cost the US economy an estimated $59.5 billion every year<br />on average professional coders make 100 to 150 errors in every 1000 lines of code they write<br />last year, canceled projects cost firms $67 billion; overruns on the other projects racked up another $21billion<br />
    14. 14. Need something a little more concrete?<br />
    15. 15. USS Yorktown, SmartShip<br />crew member entered 0 in a data entry field, caused a “divide by 0” error that shut down propulsion<br />dead in the water for 2hrs 45mins<br />
    16. 16. Ariane 5 Flight 501<br />re-used code from ariane 4, but took a different flight path because of different booster design<br />conversation from 64bit float to 16bit signed int caused overflow (exception handler was disabled for perf reasons)<br />cost: > $370 million @ 1996 prices<br />
    17. 17. F-22 Raptor<br />deploying overseas to japan the first time<br />crossed international dateline, computers crashed losing all navigation and communications systems<br />clear weather allowed them to follow tankers back to hawaii<br />Raptor is likely the most advanced manned aircraft that will ever fly…<br />
    18. 18. Need something a little more visual?<br />
    19. 19.
    20. 20.
    21. 21.
    22. 22.
    23. 23. Still Not Convinced?<br />
    24. 24. Climbing<br />Cost of Failure<br />Conditioning<br />Training<br />Training Phase<br />
    25. 25. Release<br />Cost of Bugs<br />Test<br />Development<br />Software Phase<br />
    26. 26. Push Quality Upstream<br />Release<br />Cost of Bugs<br />Test<br />Development<br />Software Phase<br />
    27. 27. Where does testing happen?<br />70% of testing happens here<br />Majority of test tools target here<br />Black Box Testing<br />White Box Testing<br />API Testing<br />
    28. 28. Visual Studio 2010<br />
    29. 29. Test Manager 2010<br />UML Modeling<br />Manual Testing<br />Layer Diagram<br />Load Testing<br />Web Testing<br />Test Case Management<br />IntelliTrace™<br />Architecture Explorer<br />Logical Class Designer<br />Cloud Development<br />Office Development<br />Windows Development<br />New WPF Editor<br />Customizable IDE<br />Multi-core Development<br />Silverlight Tools<br />Web Development<br />SharePoint Development<br />Generate from Usage<br />Static Code Analysis<br />Database Deployment<br />Code Metrics<br />Database Unit Testing<br />Test Data Generation<br />Test Impact Analysis<br />UI Test Automation<br />Code Coverage<br />Performance Profiling<br />Database Change Mgmt<br />Fast Forward for Manual Testing<br />
    30. 30. Visual Studio 2010 Test Types<br /><ul><li>Unit Test
    31. 31. Database Unit Test
    32. 32. Web PerformanceTest
    33. 33. Load Test
    34. 34. Manual Test (TestCase)
    35. 35. Generic Test
    36. 36. Ordered Test
    37. 37. Coded UI Test</li></li></ul><li>What is Unit Testing?<br />
    38. 38. Unit Test – Definition<br />A unit test is a piece of code written by a developer that exercises a very small, specific area of functionality of the code being tested.<br />“Program testing can be used to show the presence of bugs, but never to show their absence!”<br />EdsgerDijkstra, [1972] <br />
    39. 39. Manual Testing<br /><ul><li>You have already done unit testing
    40. 40. Manually, by hand
    41. 41. Manual tests are less efficient
    42. 42. Not structured
    43. 43. Not repeatable
    44. 44. Not on all your code
    45. 45. Not easy to do as it should be</li></li></ul><li>Unit Test Example<br />int Sum(int[] array)<br />{<br /> sum = 0;<br /> for (int i=0; i<array.Length; i++)<br /> sum += array[i];<br /> return sum;<br />}<br />void TestSum()<br />{<br /> if (Sum(new int[]{1,2}) != 3)<br /> throw new TestFailedException("1+2 != 3");<br /> if (Sum(new int[]{-2}) != -2)<br /> throw new TestFailedException("-2 != -2");<br /> if (Sum(new int[]{}) != 0)<br /> throw new TestFailedException("0 != 0");<br />}<br />
    46. 46. Unit Testing Some Facts<br />Tests are specific pieces of code<br />Unit testing framework is needed<br />Visual Studio Team Test<br />NUnit<br />MbUnit<br />Unit tests are written by developers, not by QA engineers<br />Unit tests are released into the code repository along with the code they test<br />
    47. 47. Unit Testing – More Facts<br />All classes should be tested<br />Test anything that could have bugs<br />All methods should be tested<br />Trivial code may be omitted <br />E.g. property getters and setters<br />Ideally all unit tests should pass before check-in into the source control repository<br />
    48. 48. Why Unit Tests?<br />Unit tests dramatically decrease the number of defects in the code <br />Unit tests improve design <br />Unit tests are good documentation<br />Unit tests reduce the cost of change<br />Unit tests allow refactoring<br />Unit tests decrease the defect-injection rate due to refactoring / changes<br />
    49. 49. Code and Test vs. Test Driven Development<br />
    50. 50. Unit Testing Approaches<br />"Code and Test" approach<br />Classical approach<br />"Test First" approach<br />Test driven development (TDD)<br />
    51. 51. Code and Test Approach<br />Write code<br />Write unit test<br />Run and succeed<br />Time flow<br />
    52. 52. Create a testlist<br />Pick а test<br />Compile and fail<br />Write enough code to compile<br />Run test and fail<br />Write code to pass test <br />Test Driven Development<br />Write test<br />Time flow<br />Remove duplication<br />
    53. 53. Why Test Driven Development?<br />Helps find design issues early and avoids rework<br />Writing code to satisfy a test is a focused activity – less chance of error<br />Tests will be a more comprehensive than when written after code<br />
    54. 54. Unit Testing Frameworks and Visual Studio Team Test<br />
    55. 55. Unit Testing Frameworks<br />JUnit<br />The first popular unit testing framework<br />Based on Java<br />Similar frameworks have been developed for a broad range of computer languages<br />NUnit – for C# and all .NET languages<br />cppUnit, jsUnit, PhpUnit, PerlUnit, ...<br />Visual Studio Team Test (VSTT)<br />Developed by Microsoft, integrated in VS<br />
    56. 56. Visual Studio Team Test – Features<br />Team Test (TT) is very well integrated with Visual Studio<br />Create test projects and unit tests<br />Execute unit tests<br />View execution results<br />View code coverage<br />Located in the assembly Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll<br />
    57. 57. Visual Studio Team Test – Attributes<br />Test code is annotated using custom attributes<br /><ul><li>[TestClass]– denotes a class holding unit tests
    58. 58. [TestMethod]– denotes a unit test method
    59. 59. [ExpectedException]– test causes an exception
    60. 60. [Timeout]– sets a timeout for test execution
    61. 61. [Ignore]– temporary ignored test case
    62. 62. [ClassInitialize], [ClassCleanup]– setup / cleanup logic for the testing class
    63. 63. [TestInitialize], [TestCleanup]– setup / cleanup logic for each test case</li></li></ul><li>Assertions<br />Predicate is a true / false statement <br />Assertion is a predicate placed in the program code <br />Indicates that the developer thinks that the predicate is always true at that place<br />If an assertion fails, the method call does not return and an error is reported<br />Example:<br />Assert.AreEqual(expectedValue, actualValue, <br />"Error message.");<br />
    64. 64. VSTT – Assertions<br />Assertions check condition and throw exception if condition is not satisfied<br />Comparing values<br />AreEqual(expected value, calculated value [,message]) – compare two values for equality<br />Comparing objects<br />AreSame(expected object, current object [,message])– compare object references<br />
    65. 65. VSTT – Assertions (2)<br />Checking for null value<br />IsNull(object [,message])<br />IsNotNull(object [,message])<br />Conditions<br />IsTrue(condition)<br />IsFalse(condition)<br />Forced test fail<br />Fail(message)<br />
    66. 66. The 3A Pattern<br />Arrange all necessary preconditions and inputs<br />Act on the object or method under test<br />Assert that the expected results have occurred<br />[TestMethod]<br />public void TestDeposit()<br />{<br />BanckAccount account = new BanckAccount();<br />account.Deposit(125.0);<br />account.Deposit(25.0);<br />Assert.AreEqual(150.0, account.Balance, <br />"Balance is wrong.");<br />}<br />
    67. 67. VSTT – Example<br />public class Account<br />{<br />private decimal balance;<br />public void Deposit(decimal amount)<br />{<br /> this.balance += amount;<br />}<br />public void Withdraw(decimal amount)<br />{<br /> this.balance -= amount;<br />}<br />public void TransferFunds(<br />Account destination, decimal amount)<br /> { ... }<br />public decimal Balance<br />{ ... }<br />}<br />
    68. 68. VSTT – Example (2)<br />using Microsoft.VisualStudio.TestTools.UnitTesting;<br />[TestClass]<br />public class AccountTest<br />{<br /> [TestMethod]<br /> public void TransferFunds()<br /> {<br /> Account source = new Account();<br />source.Deposit(200.00M);<br /> Account dest = new Account();<br /> dest.Deposit(150.00F);<br /> source.TransferFunds(dest, 100.00F);<br /> Assert.AreEqual(250.00F, dest.Balance);<br /> Assert.AreEqual(100.00F, source.Balance);<br /> }<br />}<br />
    69. 69. VSTT – Screenshot<br />
    70. 70. Visual Studio Team Test<br />Live Demo<br />
    71. 71. Unit Testing Best Practices<br />
    72. 72. Naming Standards for Unit Tests<br />The test name should express a specific requirement that is tested<br />Usually prefixed with [Test]<br />E.g. TestAccountDepositNegativeSum()<br />The test name should include<br />Expected input or state <br />Expected result output or state<br />Name of the tested method or class<br />
    73. 73. Naming Standards for Unit Tests Example<br />Given the method:<br /> with requirement to ignore numbers greater than 100 in the summing process<br />The test name should be:<br />Sum_NumberIgnoredIfGreaterThan100<br />public int Sum(params int[] values)<br />
    74. 74. When Should a Test be Changed or Removed?<br />Generally, a passing test should never be removed<br />These tests make sure that code changes don’t break working code<br />A passing test should only be changed to make it more readable<br />When failing tests don’t pass, it usually means there are conflicting requirements<br />
    75. 75. When Should a Test be Changed or Removed? (2)<br />Example:<br />New features allows negative numbers<br />[ExpectedException(typeof(Exception), <br /> "Negatives not allowed")]<br />void Sum_FirstNegativeNumberThrowsException()<br />{<br /> Sum (-1,1,2);<br />}<br />
    76. 76. When Should a Test be Changed or Removed?(3)<br />New developer writes the following test:<br />Earlier test fails due to a requirement change<br />void Sum_FirstNegativeNumberCalculatesCorrectly()<br />{<br />int sumResult = sum(-1, 1, 2);<br />Assert.AreEqual(2, sumResult);<br />}<br />
    77. 77. When Should a Test be Changed or Removed? (4)<br />Two course of actions:<br />Delete the failing test after verifying if it’s valid<br />Change the old test:<br />Either testing the new requirement<br />Or test the older requirement under new settings<br />
    78. 78. Tests Should Reflect Required Reality<br />What’s wrong with the following test?<br />A failing test should prove that there is something wrong with the production code<br />Not with the unit test code<br />int Sum(int a, int b) –> returns sum of a and b<br />public void Sum_AddsOneAndTwo()<br />{<br /> int result = Sum(1,2);<br /> Assert.AreEqual(4, result, "Bad sum");<br />}<br />
    79. 79. What Should Assert Messages Say?<br />Assert message in a test is one of the most important things<br />Tells us what we expected to happen but didn’t, and what happened instead<br />Good assert message helps us track bugs and understand unit tests more easily<br />Example:<br />"Withdrawal failed: accounts are not supposed to have negative balance."<br />
    80. 80. What Should Assert Messages Say? (2)<br />Express what should have happened and what did nothappen<br />“Verify() did not throw any exception”<br />“Connect() did not open the connection before returning it”<br />Do not:<br />Provide empty or meaningless messages <br />Provide messages that repeat the name of the test case<br />
    81. 81. Avoid Multiple Asserts in a Single Unit Test<br />void Sum_AnyParamBiggerThan1000IsNotSummed() <br />{<br /> Assert.AreEqual(3, Sum(1001, 1, 2);<br /> Assert.AreEqual(3, Sum(1, 1001, 2);<br /> Assert.AreEqual(3, Sum(1, 2, 1001);<br />}<br />Avoid multiple asserts in a single test case<br />If the first assert fails, the test execution stops for this test case<br />Affect future coders to add assertions to test rather than introducing a new one<br />
    82. 82. Unit Testing – The Challenge<br />The concept of Unit Testing has been around for many years<br />New methodologies in particular XP, have turned unit testing into a cardinal foundation of software development<br />Writing good & effective Unit Tests is hard!<br />This is where supporting integrated tools and suggested guidelines enter the picture<br />The ultimate goal is tools that generate unit tests automatically<br />
    83. 83. What is a load test?<br /><ul><li>An automated collection of tests run in parallel to simulate multiple users or systems
    84. 84. Load tests run software unit tests, database unit tests, and web performance tests
    85. 85. Visual Studio captures details metrics while the load test runs</li></li></ul><li>Load Test Concepts<br />Scenario<br /><ul><li>A collection of load test parameters that simulate real world scenario.</li></ul>Load Pattern<br /><ul><li>Determines the number of users the scenario simulates. May be constant or stepped to simulate an increasing number of users</li></ul>Test Mix<br /><ul><li>Determines the unit tests and web tests.</li></ul>Network Mix<br /><ul><li>Determines the connection speeds used by virtual users</li></ul>Run Settings<br /><ul><li>A set of properties that determine the way the load test runs</li></li></ul><li>Core Scenarios<br /><ul><li>Single user performance testing
    86. 86. Create and debug Web Performance Tests
    87. 87. Use Coded UI tests to measure end user performance
    88. 88. Run performance tests
    89. 89. Analyze results
    90. 90. Report to stakeholders
    91. 91. Fix the problems using the profiler</li></li></ul><li>Network Emulation<br /><ul><li>Productizing NEWT network device driver
    92. 92. Throttles bandwidth, introduces latency and errors at the network layer
    93. 93. Scenarios
    94. 94. Single user testing over slow network
    95. 95. Automated performance testing over slow links</li></li></ul><li>Web Performance Test Recorder<br />Visual Studio Launches Internet Explorer<br />RecorderListener<br />Browser Recorder<br />Wininet Recorder<br />Merging Recorder<br />Internet Explorer<br />Visual Studio<br />Recorder BHO<br />Browser events<br />Record events<br />Browser Control<br />Wininet Shim<br />Record events<br />Wininet<br />Record events<br />Intercepts wininet calls<br />
    96. 96. Web Test Recorder Plugin<br />WebTestRecorderPlugins<br />Visual Studio Launches Internet Explorer<br />RecorderListener<br />Browser Recorder<br />Wininet Recorder<br />Merging Recorder<br />Internet Explorer<br />Visual Studio<br />Recorder BHO<br />Browser events<br />Recorded Web Test<br />Record events<br />Browser Control<br />Wininet Shim<br />Recorder Result<br />Wininet<br />Record events<br />Intercept s wininet calls<br />Record events<br />
    97. 97. Load Test Agent Architecture<br />Test agents run tests and collect data<br />Test agent #1<br />Test agent #2<br />Test agent #3<br />Test Agent<br />Run Tests<br />Visual Studio Ultimate 2010<br />Test Controller<br />Target Server<br />Collector<br />Agent<br />Asp.Net<br />Profiler<br />Test Controller manages test agents<br />
    98. 98. Visual Studio Team Test<br />Live Demo<br />
    99. 99. ?<br />?<br />?<br />?<br />?<br />Questions?<br />?<br />?<br />?<br />?<br />?<br />
    100. 100. Patrocinadores desta reunião<br />
    101. 101. Próximas reuniões presenciais<br />09/04/2011 - Abril (Coimbra)<br />16/04/2011 - Abril (Lisboa)<br />21/05/2011 - Maio (Lisboa)<br />18/06/2011 - Junho (Lisboa)Reserva estes dias na agenda! :)<br />
    102. 102. Obrigado!<br />Pedro Rosa<br />http://pt.linkedin.com/in/pedrobarraurosa<br />http://twitter.com/pedrorosa<br />

    ×