V1.0
How often do you get a bug report that you can’t reproduce?
How often do you struggle to find the source of the bug in your code?
How can you streamline the testing process and make sure you don’t repeat the same bugs?
With Visual Studio 2010 & Team Foundation Server (TFS) 2010 there are a lot of new features for testers and developers that will solve these problems.
In this session you will learn how to: automate more, reproduce bugs easier, maintain your tests and configuration and discover problems sooner.
from Peter Gfader
2. Testing the world with Visual Studio 2010 How often do you get a bug report that you can’t reproduce? How often do you struggle to find the source of the bug in your code? How can you streamline the testing process and make sure you don’t repeat the same bugs? With Visual Studio 2010 & Team Foundation Server (TFS) 2010 there are a lot of new features for testers and developers that will solve these problems. In this session you will learn how to: automate more, reproduce bugs easier, maintain your tests and configuration and discover problems sooner. Abstract
3. In every day software development, we often encounter bugs that are difficult to reproduce and even more difficult to find. This problem is accentuated when it’s a reoccurring bug in the system. Visual Studio 2010 & Team Foundation Server (TFS) 2010 introduces heaps of new features that will help testers and developers in squashing these bugs once and for all. In this session you will learn how to: Reproduce bugs Automate your tests to find reoccurring bugs Maintain your tests and configuration Discover problems sooner Abstract
4. SSA @ SSW Loves C# and .NET (Java not anymore) Specializes in Windows Forms ASP.NET TFS testing Automated tests Peter Gfader
5. How to report bugs What to test to find bugs? Tests Unit tests Integration test Testing, reporting bugs and fixing bugs Test & Lab Manager (MTLM) VS2010 Missing in VS2010 Agenda
9. Email Web application TFS web access How do you report bugs?
10.
11.
12. And we love emailsTeamCompanion glues those worlds together http://www.ssw.com.au/ssw/standards/rules/rulestobetterprojectmanagementwithtfs.aspx#TeamCompanionWorkItem How we report bugs
13. Instructions to tester Reproduce steps Screen captures Stacktrace (Windows Forms, WPF, ASP.NET, Silverlight) Win7 Recorder? How do you report bugs (Instructions)?
14. Reproduce steps Screen captures Stacktrace (Windows Forms, WPF, ASP.NET, Silverlight) Win7 Recorder ??? URL (Page) Version number Browser (Firefox or IE) http://www.ssw.com.au/ssw/standards/Support/BugReportOrEnhancement.aspx Instructions to tester
21. ** Triaging rule Runtime error this release Suggestions / feature next release Little UI ones this release ** RULE Do you have rules on triaging?
22. ** add pix Ryan His favourite quote “Test failed – 5 critical bugs found” Do you have a dedicated tester?
23. Code UI DB Deployment Reports Performance Security Whole system User requirements fulfilled What do we want to test?
25. What is the problem here? 1. What are we testing? [TestMethod] publicvoidTestCalculation() { varorderManager = newOrderManager(); using (var db = newNorthwindDataContext()) { var order = db.Orders.FirstOrDefault(); var actual = orderManager.GetTotalIncGST(order); var expected = order.OrderItems.Sum(oi => oi.Qty * price) * 1.1; Assert.AreEqual(actual, expected); } } 2.
26. “A unit test is a fast, in-memory, consistent, automated and repeatable test of a functional unit-of-work in the system.” “A unit of work is any functional scenario in the system that contains logic. It can be as short as a function, or it can span multiple classes and functions, and it provides internal or business value to the system under test.” “Art of Unit Testing” Roy Osherove What is a Unit test?
27. It talks to the database It communicates across the network It touches the file system It can't run at the same time as any of your other unit tests You have to do special things to your environment Configuration files, registry, ... Michael Feathers What is NOT a Unit test?
28. Integrates different pieces UI Business Layer Database Not in memory Touches File system Registry Database Other shared resources Integration test
29. Run much slower not run in-memory Less consistent Dependent from external resources Has side effects Harder to prepare E.g. Database setup Integration test
30. Unit tests – ALWAYS Integration tests – “allow” to be red Why is this important?
31. Readable Understand! What? Scenario? Expectation? Maintainable We change our application Trustworthy All We are bug free Attributes of a good Unit test
39. [TestMethod] publicvoid DataContextSubmitChangesValidateDirtyObjects_RuleResultSavedMeasureTime_RunProcessorAfterInsert5Shifts() { for (inti = 0; i < 5; i++) { //dummy entries DbHelper.CreateNewEmployeeShift( DbHelper.EmployeeId1SouthSuperIntendentEast, "01/01/2000 15:00“, "01/01/2000 16:00“, true); } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); RuleProcessor.Default.Start(); System.Threading.Thread.Sleep(2000); RuleProcessor.Default.Stop(); stopwatch.Stop(); // no dirty object left vardirtyObjects = DbHelper.GetDirtyObjects(); Assert.IsTrue(dirtyObjects.Count() == 0,"Dirty objects found"); }
40. Hard to see Naming convention Unit test Test single small “unit of work” Integration test Test integration, functionality Unit test vs. Integration test
41. Test & Lab Manager (MTLM) VS2010 TestingReporting bugsFixing bugs
47. Dev: We have 2 additionally reported bugs PM: No time to fix bugs... We must SHIP! We call this the “Vista method” Finally at the end of Test phase
48. 2 weeks development BANG Tester has no plan – Exploratory testing Tester tests everything “Unable to reproduce” = “Works on my machine” Bug never gets fixed Ship a buggy product Problems
61. Bug in TFS Video.wmv Detailed steps IntelliTrace (drill through to Visual Studio) Automated recording Lots of details (you don’t need if you get intelliTrace) Stack trace System info What’s good?
65. From recorded test we create an automated test Don’t fix bug yet#5 Create automated test
66.
67.
68.
69. Changes to the test //Arrange ApplicationUnderTestappUT = ApplicationUnderTest.Launch(@”bin86ebugvalonCalculator2.exe"); //Act // SNIP SNIPSNIP //Assert Assert.IsTrue(appUT.Process.Responding, "App not responding");
74. Easy to reproduce the bug Create functional test (coded UI test) Automate the test from recording Good for future changes (Regression testing) What’s good with coded UI tests
81. Was called “Historical Debugging” Easy to spot the bug Record method calls with parameters Advanced call stack Get intellitrace logs from your testers Record / Trace testers execution Use same source code to debug as the tester had to test Get intellitrace logs from your build server What’s good in IntelliTrace
82. Hi Ryan Done – Fixed and test added PS: you don’t need to test this again PPS: testers are becoming less useful with 2010 Peter #8 Email to tester
93. Test impact analysis The developer sees that his code affected other tests (Test Impact analysis) Saves time on running tests Running a lot of tests is slow
105. Label breakpoints Searching in the Breakpoints window Export and Import of Breakpoints and Data Tips (put under source control for all devs) Breakpoints Window
107. Email Web application TFS web access Test & Lab Manager Which one would you use now?
108.
109. When you get a bug report! Create test Test is RED Fix bug Test is GREEN Send a “Done - Test created” When do you create a test?
110. Reproduce bug Spot bug “Works on my machine” Bug never gets fixed Generate test from bug Dev uses “Re-play” button instead of manual test Recap Scenario
111.
112. Every time I change something I want to test (verify) that I didn’t introduce a bug Deployment Bug fix New feature New report added I love automated tests
113. Integrated web UI tests Windows UI tests, when they do it for Web, they can do it for Windows apps (Windows Forms, WPF) RowTests Data driven tests with attributes next to the test What I want in VS2012
116. Roy Osherove Book http://www.artofunittesting.com/ Blog http://weblogs.asp.net/ROsherove/ Unit test definitionhttp://weblogs.asp.net/ROsherove/archive/2009/09/28/unit-test-definition-2-0.aspx Michael Feathers Bloghttp://www.artima.com/weblogs/index.jsp?blogger=mfeathers What is not a unit test?http://www.artima.com/weblogs/viewpost.jsp?thread=126923 Resources
117. Compare Visual Studio editionshttp://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx#compare Visual Studio pricing optionshttp://arstechnica.com/microsoft/news/2009/10/visual-studio-2010-simplified-to-four-skus-beta-2-arrives.ars Resources
118. Good blog about VS2010http://blogs.msdn.com/habibh/ How Does VS2010 Historical Debugging Work?http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/06/16/how-does-vs2010-historical-debugging-work.aspx Resources
120. Thank You! Gateway Court Suite 10 81 - 91 Military Road Neutral Bay, Sydney NSW 2089 AUSTRALIA ABN: 21 069 371 900 Phone: + 61 2 9953 3000 Fax: + 61 2 9953 3105 info@ssw.com.auwww.ssw.com.au
Editor's Notes
Peter Gfader Testing with VS2010
Java current version 1.6 Update 171.7 released next year 2010Dynamic languages Parallel computingMaybe closures
The silliest bug report ever seen ...“The worst bug report I ever seen... And actually I wrote it”
Not everyone in GermanyThis is already quite good...Stacktrace, Exception, Screenshot ...Automated exception handlerNo steps to reproduceUnable to reproduce without customer...Not easy to fix, until I know This is the answer to the problem... But I don’t know what the question is...I want steps to reproduce...You could to a lot of Trace.Writelines or use log4net or some other logging framework...I save you from all these!
Windows app?
This is another way of sending a bug. Its OKTFS web accessTester and Client can directly enter bugs into your bug tracking system
TFS + Emails + TeamCompanion
Windows app?We take that a bit further as well...Is there anything else you want to have in your bug reports?Sys infoScreen size...MHTML, short for MIMEHTML, is a web page archive format used to bind resources that are typically represented by external links (such as images, Flash animations, Java applets, audio files) together with HTML code into a single file. The content of an MHTML file is encoded as if it were an HTML e-mail message, using the MIME type multipart/related.
Do all these things....
App.xaml
SKIP THIS
We have RyanDo you have a dedicated tester?That does just testing? No coding? Not on the same project...
Integrate the whole system
Relies on entries in the database, should use in memory/mock objectsWhat are we testing here?Naming of Test should reflect: What are we testing? Scenario: Input values, Behaviour,
Tests that span multiple layers (for example business logic, view, and controller) are also not considered unit tests You have to do special things to your environment (such as editing config files) to run it.
how is it different that an integration test?An integration test usually is not in-memory: it may touch the disk file system, databases, registry or other shared resources. It may read or need a configuration file of the file system, wheas a unit test can be fully configured in-memory, for example.An integration test will usually run much slower because it does not run in-memory.An integration test can be less consistent – it may use threads or random number generators so that the result of the test is not always consistent.---
An integration test will usually run much slower because it does not run in-memory.An integration test can be less consistent – it may use threads or random number generators so that the result of the test is not always consistent.---– it may use threads or random number generators so that the result of the test is not always consistent.
Integration test: Test on physical serverIntegration tests: Should be setup env. Themselves and tear down afterwardsDateTime.Now Moq:MDateTime
Readable: Easy to understand, see what we are testing, why, expectMaintainable: If they are to hard to maintain they’ll get stale, and your investment in writing them was wasted. Trustworthy: If you can’t trust your tests to find bugs (and especially if you don’t know you can’t trust them), then the opposite may be true — you may be confident you don’t have bugs when you do.
Don’t repeat the same logic in the test!Bug is reproduced in test!
No detailed planCreate click sequence that is out of the mainstream
Magic moment when we close tasks:Dev: “Should be fine now”“Unable to reproduce” = “Works on my machine”“Unable to reproduce” is just as silly as “works on my mach”Every time you choose that, the screen should come up
No time to fix all bugs --> We must SHIP (we call this the “Vista method”) #8
How often do you get a bug report that you can’t reproduce? How often do you struggle to find the source of the bug in your code?
Start up “Microsoft Test and LabManager”
ONLY IN Visual Studio Ultimate edition
Tester sees tests to doWe pick test division by 0
“Create action recording” - To reproduce steps
TestCaseCollectorErrorWarning.xml =WarningErrors from MTLM<?xml version="1.0" encoding="UTF-8"?><DataCollectionLogxmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> <DataCollectorMessages> <DataCollectorExceptionMessage timestamp="2009-11-14T22:26:52.7623220+11:00" dataCollectorUri="datacollector://microsoft/VideoRecorder/1.0" dataCollectorFriendlyName="Video Recorder" agentName="WIN-M3V9YMSUKRG" level="Error"> <Text>A video recording cannot be created</Text> <ExceptionType>Microsoft.VisualStudio.TestTools.Execution.WindowsMediaEncoderNotInstalledException</ExceptionType> <ExceptionMessage>To create a video recording, follow the instructions on the following link to install any necessary software:http://go.microsoft.com/fwlink/?LinkId=154778</ExceptionMessage> </DataCollectorExceptionMessage> <DataCollectorMessage timestamp="2009-11-14T22:29:45.6272345+11:00" dataCollectorUri="datacollector://microsoft/TraceDebugger/1.0" dataCollectorFriendlyName="IntelliTrace" agentName="WIN-M3V9YMSUKRG" level="Warning"> <Text>No Microsoft .NET applications were launched during the test run. Launch applications from Explorer or a new command prompt after a test case has started. If no .NET application is being tested, disable the Test Impact and IntelliTrace Data Collectors.</Text> </DataCollectorMessage> <DataCollectorMessage timestamp="2009-11-14T22:29:45.6321170+11:00" dataCollectorUri="datacollector://microsoft/TraceDebugger/1.0" dataCollectorFriendlyName="IntelliTrace" agentName="WIN-M3V9YMSUKRG" level="Warning"> <Text>The data collector is configured to collect data from IIS, but no web request was intercepted during the test. Ensure that the "ASP.NET Client Proxy for IntelliTrace and Test Impact" is enabled in the client test settings and that "localhost" or "127.0.0.1" is not being used to contact the server. This warning is expected if the test is not testing a web application or web service on the IIS server.</Text> </DataCollectorMessage> </DataCollectorMessages></DataCollectionLog> ActionLog.txt Log fileUse this to create a test
What does the dev get?BAD: the tdlog (intelliTrace) is huge > 10MB of this exception
Trace (intelliTrace) is there in this bug (All Links)Uitest is there as well
Stacktrace is good...We don’t need it anymore...We see the error in yellow!!** Balloons over this
Balloon on exception on the transitionHOVER OVER d and see NAN: NOT POSSIBLE?
[TestMethod] public void CodedUITestMethod1() {ApplicationUnderTestappUT = ApplicationUnderTest.Launch(@"c:DataPeterGfaderProjectsTFSPeter-Gfader-Calculator runkWPFCalculatorcsharpinx86DebugAvalonCalculator2.exe"); // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items. this.UIMap.Press2();this.UIMap.PressDivide(); this.UIMap.Press0();this.UIMap.PressEquals();Assert.IsTrue(appUT.Process.Responding, "App not responding"); // cleanupappUT.Close(); }
Bug can be fixed directly in debugging session – since on same machine...Not sure if that’s the case when tester is on another machine...
BAD: the tdlog (intelliTrace) is huge > 10MB for this exception (1minute)
Think of falling asleep during a movie... Then you wake up suddenly because a shot happened in the movie. Now you rewind back to see what happened...Now imagine this with an exception (=shot)
Think of falling asleep during a movie... Then you wake up suddenly because a shot happened in the movie. Now you rewind back to see what happened...Now imagine this with an exception (=shot)
Think of falling asleep during a movie... Then you wake up suddenly because a shot happened in the movie. Now you rewind back to see what happened...Now imagine this with an exception (=shot)
Dev shouldn’t close the bugDev just says: Resolved
nDepend
Create sequence diagram -> context menu on method
"That is all I have for today. I appreciate you giving me your time. Thank you very much and have a great day." Peter Gfader
Menu doesn’t hop up and down on switching projects...
Adding more values (including notes) to data tipsIs this in source control? otherwise ???
Searching in the Breakpoints windowLabel breakpointsImport and export breakpoints (put under source control for all devs)String comparison for breakpoint conditions in native debuggingExport and Import of Breakpoints and Data Tips
Windows app?
Similar to TDD...
Click to add notesPeter Gfader Testing with VS2010