SlideShare une entreprise Scribd logo
1  sur  55
Getting to know MSTest With Visual Studio 2010 and   Team Foundation Server 2010 Thomas Weller www.thomas-weller.de info@thomas-weller.de July 2010
Outline Authoringtests (withMSTest)   Visual Studio 2010   Team Foundation Server 2010 Advancedtestingconcepts   UI Automation
What‘s in a test ? ,[object Object]
  What makes a good (unit) test...
  Test context
  Initalize/Cleanup
  Attributes:
  [ExpectedException]
  [Description]
  [TestProperty]
  [TestCategory]	,[object Object]
Anatomy of a test class (I) ,[object Object]
  Containing class: [TestClass]
  Test: [TestMethod], public void, paramless,[object Object]
  Throws a special exception to fail a test
StringAssert, CollectionAssert …,[object Object]
  Arrange
  Act
  Assert,[object Object]
 try to isolate code under test
 short – simple – fast (CI) – readable
 Test    documentation, usage example
nodependencies on other tests     (random order!)
TestContext class ,[object Object]
WriteLine()for additional info in test results:,[object Object],[object Object]
  all methods are optional,[object Object]
  also Exception messages, if needed,[object Object]
  shows up in the Properties window:,[object Object]
  show up in the Properties window:,[object Object]
  filter by category on automated builds:,[object Object]
  apply to test methods as appropriate:,[object Object]
  Test lists/metadata (*.vsmdi)
  Tool Windows:
Test Viewwindow
Test List Editor window
Test Resultswindow
Test Runs window
Test Results Details window,[object Object],[object Object]
   e.g. for different test runs
   similar use to that of TestCategory attribute
   edit with Test List Editor window (see below)
  *.vsmdi   *.xml,[object Object],[object Object],[object Object],[object Object]
Team Foundation Server 2010 ,[object Object]
  Creating a Bug work item
  Creating the test
  Creating a Test Case work item for the Bug
  Associating test and work item
  Check in
Tests and Automated Builds,[object Object]
  Visual Studio (Team Explorer):,[object Object]
Writing the test
Create a Test Case for the Bug ,[object Object],[object Object]
  From work item:,[object Object]
  version history:,[object Object]
Some more advanced concepts ,[object Object]

Contenu connexe

Tendances (20)

TypeScript - An Introduction
TypeScript - An IntroductionTypeScript - An Introduction
TypeScript - An Introduction
 
Android MVVM
Android MVVMAndroid MVVM
Android MVVM
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Automated Testing vs Manual Testing
Automated Testing vs Manual TestingAutomated Testing vs Manual Testing
Automated Testing vs Manual Testing
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
.Net Core
.Net Core.Net Core
.Net Core
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Typescript ppt
Typescript pptTypescript ppt
Typescript ppt
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Testing Spring Boot Applications
Testing Spring Boot ApplicationsTesting Spring Boot Applications
Testing Spring Boot Applications
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
Java PPT
Java PPTJava PPT
Java PPT
 
Express js
Express jsExpress js
Express js
 
Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
AngularJS
AngularJSAngularJS
AngularJS
 
Spring boot
Spring bootSpring boot
Spring boot
 

En vedette

Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctlyDror Helper
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010kgayda
 
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java Code
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java CodeJava Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java Code
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java CodeEdson Yanaga
 
Presentation on Visual Studio
Presentation on Visual StudioPresentation on Visual Studio
Presentation on Visual StudioMuhammad Aqeel
 
Visual Studio 2012
Visual Studio 2012Visual Studio 2012
Visual Studio 2012Byron Paguay
 
Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming francopw
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)pbarasia
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Salim M
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computersimran153
 

En vedette (14)

NUnit vs MSTest
NUnit vs MSTestNUnit vs MSTest
NUnit vs MSTest
 
Building unit tests correctly
Building unit tests correctlyBuilding unit tests correctly
Building unit tests correctly
 
.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010.Net Unit Testing with Visual Studio 2010
.Net Unit Testing with Visual Studio 2010
 
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java Code
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java CodeJava Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java Code
Java Craftsmanship: Lessons Learned on How to Produce Truly Beautiful Java Code
 
Presentation on Visual Studio
Presentation on Visual StudioPresentation on Visual Studio
Presentation on Visual Studio
 
Visual Studio IDE
Visual Studio IDEVisual Studio IDE
Visual Studio IDE
 
Visual studio introduccion
Visual studio introduccionVisual studio introduccion
Visual studio introduccion
 
Visual Studio 2012
Visual Studio 2012Visual Studio 2012
Visual Studio 2012
 
Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming Chapter 1 — Introduction to Visual Basic 2010 Programming
Chapter 1 — Introduction to Visual Basic 2010 Programming
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Visual Basic Controls ppt
Visual Basic Controls pptVisual Basic Controls ppt
Visual Basic Controls ppt
 
Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0Basic controls of Visual Basic 6.0
Basic controls of Visual Basic 6.0
 
Visual basic ppt for tutorials computer
Visual basic ppt for tutorials computerVisual basic ppt for tutorials computer
Visual basic ppt for tutorials computer
 

Similaire à Introduction to testing with MSTest, Visual Studio, and Team Foundation Server 2010

Coded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewCoded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewOmer Karpas
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Comunidade NetPonto
 
End To End Build Automation With Team Build
End To End Build Automation With Team BuildEnd To End Build Automation With Team Build
End To End Build Automation With Team Buildwbarthol
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksTsimafei Avilin
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit TestingJames Phillips
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010Ed Blankenship
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009Pepe
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMSJustinHolt20
 
Robotium framework & Jenkins CI tools - TdT@Cluj #19
Robotium framework & Jenkins CI tools - TdT@Cluj #19Robotium framework & Jenkins CI tools - TdT@Cluj #19
Robotium framework & Jenkins CI tools - TdT@Cluj #19Tabăra de Testare
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android ApplicationsRody Middelkoop
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_completebinuiweb
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power pointjustmeanscsr
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010Abram John Limpin
 
Automation test
Automation testAutomation test
Automation testyuyijq
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and DebuggingRich Helton
 

Similaire à Introduction to testing with MSTest, Visual Studio, and Team Foundation Server 2010 (20)

Coded ui - lesson 1 - overview
Coded ui - lesson 1 - overviewCoded ui - lesson 1 - overview
Coded ui - lesson 1 - overview
 
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...Testes? Mas isso não aumenta o tempo de projecto? Não quero...
Testes? Mas isso não aumenta o tempo de projecto? Não quero...
 
Modern Python Testing
Modern Python TestingModern Python Testing
Modern Python Testing
 
Gallio Crafting A Toolchain
Gallio Crafting A ToolchainGallio Crafting A Toolchain
Gallio Crafting A Toolchain
 
End To End Build Automation With Team Build
End To End Build Automation With Team BuildEnd To End Build Automation With Team Build
End To End Build Automation With Team Build
 
UI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricksUI Automation_White_CodedUI common problems and tricks
UI Automation_White_CodedUI common problems and tricks
 
Stopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under TestStopping the Rot - Putting Legacy C++ Under Test
Stopping the Rot - Putting Legacy C++ Under Test
 
Ef Poco And Unit Testing
Ef Poco And Unit TestingEf Poco And Unit Testing
Ef Poco And Unit Testing
 
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
 
Full Testing Experience - Visual Studio and TFS 2010
 Full Testing Experience - Visual Studio and TFS 2010 Full Testing Experience - Visual Studio and TFS 2010
Full Testing Experience - Visual Studio and TFS 2010
 
12 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 200912 Rational Solo Pruebas 2009
12 Rational Solo Pruebas 2009
 
Testing in Craft CMS
Testing in Craft CMSTesting in Craft CMS
Testing in Craft CMS
 
Robotium framework & Jenkins CI tools - TdT@Cluj #19
Robotium framework & Jenkins CI tools - TdT@Cluj #19Robotium framework & Jenkins CI tools - TdT@Cluj #19
Robotium framework & Jenkins CI tools - TdT@Cluj #19
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
10071756.ppt
10071756.ppt10071756.ppt
10071756.ppt
 
A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010A Lap Around Visual Studio 2010
A Lap Around Visual Studio 2010
 
Automation test
Automation testAutomation test
Automation test
 
C# Security Testing and Debugging
C# Security Testing and DebuggingC# Security Testing and Debugging
C# Security Testing and Debugging
 

Dernier

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Dernier (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Introduction to testing with MSTest, Visual Studio, and Team Foundation Server 2010

Notes de l'éditeur

  1. Gives an introduction to writing tests (along with some best practices) with the MSTest frameworkin the context of Visual Studio 2010and Team Foundation Server 2010and presents some advanced concepts and techniques that go beyond those very simple (but mostly - practically - useless) introductory examples.
  2. This presentation has the following parts:Gives a first overview of a test method in MSTest other Testing frameworks (e.g. Nunit, MbUnit, xUnit.Net) are similar, mostly only syntactical differencesDemonstrates how testing is a part of Visual Studio (2010)the various tool windows that VS providesand how to work with them.Shows a sample workflow in the broader context of the Team Foundation server environmentPresents some more ‚advanced‘ concepts of Unit Testing(but you can‘t do without them when it comes to real-life scenarios)Shows some additional toolsLast not least: automated UI TestingMost difficult and complicated part of TestingPresents a strategy for WPF along with the required tools
  3. What does a ‚test class‘ look like, how can I write such a thing?Some important rules to keep in mind when authoring tests.The TestContext class in the MSTest frameworkWhat is it?Why is it important?What do I need it for?The various Initialize/Cleanup attribute pairsWhat is it?Why is it important?What do I need it for?Some useful attributes
  4. The sample class that I use as a test target for my simple examples, along with a corresponding interface.Very simple, self-explaining (hopefully...).
  5. A test class is nothing but an ordinary C# class.A test method is nothing but an ordinary C# method. (Signature is public void,no arguments).Marked as test class/method only by attributes.
  6. A test of course tests something.. i.e. it (mostly) asserts some value (variable, field, property...)Assert class (static) – such a class is common to all testing frameworksMS ‚additionally‘ provides some specialized Assert classes for strings etc.Assert classes throw exceptions (keep in mind when working with try/catch inside your tests)
  7. A test should always have the so-called triple-A structure:Arrange: Prepare everything for your test (e.g. initialize values...). This is usually the most complicated part of a test.Act: Execute the action that you want to test.Assert: Check that the outcome actually is as you would expect.
  8. Some guidelines for writing tests (‚best practices‘):One test asserts only one thingeven if this may be trivialMostly (but not always) this means: One AssertA test tends to be useless if the tested class/method depends on other classes/methods or external resourcesSuch a test has multiple reasons to fail, so what does the result ‚Failed‘ mean in such a case?The outcome of the test may depend upon external systems (e.g. database/network)A ‚unit test‘ is by definition an isolated test (otherwise it‘s a ‚(integration) test‘, but not a ‚unit test‘...)Remember that all of our tests are run in our Continuous Integration build system on each check-inexcept you explicitely excluded them for some reasonTests have to be fast (you may end up with hundreds or even thousands of them)A good test is the best documentation that a programmer can ever wish forIntention-revealing usage exampleTest runners (not only MSTest) by default run the tests in random orderNo dependencies, no ordering (you could do that with MSTest, but it‘s a bad smell)Think of a test as a complete execution unit
  9. The TestContext class is a singleton, specific to the current test runprovided by the MsTest framework, accessible in all test classesthink of it as your access point to the runtime environmentProvides methods to output custom text messagesProvides access to external resources (e.g. files, db connections...)Slide shows a sample where a text message is written, along with its appearance in the Test Result Details window.
  10. Property is automatically set by framework during initialization.
  11. There are pairs of Initialize/Cleanup methods on three levelsUse them (as the name suggests) to perform common initializations and cleanupagain: ordinary methods, identified by attributesall of the methods are optional, so pick the ones you need
  12. Attribute is used to assert that an exception of a specific type was thrown.You can also check for specific text in the exception message, should that be necessary (not shown here).
  13. Used to attach some custom explanatory text to the test method.Shows up in the Properties tool window.
  14. Attach any name/value pairs to a test method.Shows up in the Properties tool window (additional rows).
  15. Attach any number of categories to a test method (string).Useful for easy filtering in Test lists and CI builds.
  16. Useful usage example: Define test categories to control when a test should run.
  17. This part of the presentation shows you how the MSTest testing framework is integrated in Visual Studio.First, there are two configuration files, you need to know about (both are xml-format):The test run configuration (machine-specific, you can have as many as required)Test lists (useful for various purposes)Second, I will show you the various tool windows that VS provides for working with tests, and how they can be used.Side note:Visual Studio also has a feature to automatically generate a test class along with all test methods for a given class. I won‘t show this here for two reasons:It‘s not in the spirit of Test-driven development, because it already assumes some code to be tested. It‘s something that comes from a ‚test-after‘ philosophy. Therefore you better don‘t get used to it and the workflow it implies.The generated code is quite sloppy, with lots of unnecessary blank lines and useless comments. As a result, it takes more time to clean up and reorganize the generated code than it takes to write the few necessary lines from scratch.This is not to say that it‘s completely useless. Rather it depends on the specific scenario – as always. Just check it out, it‘s self-explaining...
  18. Test run configurations are used to adapt the test run to a specific machine. The build machine may need settings that are slightly different from your development machine.Notes:Beware that there are also settings that should be the same in all test settings (e.g. Timeout values)Be sure to have the ‚Enable deployment‘ checkbox checked, if you work with any files.Ideally you will only ever need one settings file.
  19. Test lists allow to create custom lists of test methods, that can be run with one click from Visual Studiop. They can be useful in various ways, e.g.:When developing a feature, you can collect all the relevant tests in a list to always have them easily available.You can define different test lists for different purposes/scenarios (you can use it for achieving the same as with the TestCategory attribute).
  20. Open via Test Results window...
  21. This part presents a simple but typical example workflow that shows how all the previously shown integrates with the new TFS environment.For a bug, the steps typically are as follows:You create a bug work item in TFS.Then you create a test that reproduces this bug.Next, you create a Test Case work item for your test and link it to your test method.Last not least: On Check-In, you link your changes to the test case.There will also be a short sidestep to show the various builds on the Build server and how they are intended.
  22. Preliminary remark:Everything in the TFS issue tracking system is a so-called Work Item. There are different types like e.g. Bugs, requirements etc. The list of available WIs depends on the Project management strategy and settings.You can create a Bug (or any other WI) either from the web-based Project Portal or from VS‘ Team Explorer.
  23. Add a meaningful title and the necessary details.
  24. Write the test that reproduces this error.(The Bug will be considered as Fixed, when this test finally will succeed...)
  25. From the details window of the Bug WI, Test Cases tab: Create a new Test Case WI.(The Test Case will be associated with the Bug, as the visualization shows)
  26. Now link the test method to the Test Case WI. You can do this from both ends:Either by browsing all tests from the Associated Automation tab of the Test Case details window.Or by right clicking on the test method in the Test View tool window and then browsing for the Test Case WI.
  27. On Check-In, associate your code with the relating Test Case WI.This association will show up in the version control‘s history.These connections greatly enhance traceability within the development system.
  28. Our build system has three different builds defined:The Continuous Integration build is triggered by each check-in (it accumulates consecutive check-ins if necessary). Therefore, it should be reasonably fast and exclude all tests that take a very long time, don‘t need to run that frequently, or are fragile for some reason. This build compiles the project in Debug Mode.Additionally, there‘s a nightly build (As the name implies, it runs each night. So you always have a fresh build when you come to work in the morning). This gives room for longer running tests as well as for long-running tasks like e.g. compilation and publishing of xml documentation (Sandcastle), deep statical analysis (FxCop, NDepend), creation of deployment packages and the like. This build compiles the project both in Debug and Release Mode.Furthermore there is a manual build (guess what: only manually triggered) which is used to finally build the solution for rollout. This build compiles the project in Release Mode and gets its sources from the read-only ‚REL‘ version-control branch (rather than from the ‚DEV‘ branch, which is our main line).The TestCategory attribute is used to define when a test shall be included/excluded. See usage example for this attribute (or the UI test method at the end).Note to readers:This reflects the configuration for the then current company environment / development team. Although this configuration reflects recommendable best practices, it doesn‘t necessarily has to be this way.
  29. Now back to some concepts that are more closely related to writing tests. While the here bespoken may ce called ‚advanced concepts‘, they are actually quite essential to your daily testing work, and you will see that in most cases you can‘t do anything useful without them.First we will look at the means that MSTest provides to access private code.Then I will show you an alternative way to do the same – it is preferable in most situations.Next I‘ll introduce you to the concept of Isolation/Mocking and present you a tool that can be used for that. Hereupon the MS Moles framework is presented with an example. It‘s said to be a mocking framework as well, but it actually is a different technical breed and you use it for slightly different things.I will end this part with the concept of ‚data-driven testing‘ (where test methods are provided with test data from outside). A data-driven test is executed once for each set of arguments (‚data row‘) that is provided by the data source. I‘ll show you examples for the two most widely used variations:The test data are provided via an xml file.The test data are provided via a database.
  30. For accessing private members, MSTest provides the PrivateObject helper class.As you can see from the list, it‘s basically a convenience wrapper that hides all the raw reflection code that you‘d have to write otherwise.For static elements, there‘s the PrivateType class (analogue to PrivateObject).
  31. Example for PrivateObject.General remark:Some consider ‚testing private members‘ a bad practice. I would not go that far - the important thing is the logic under test, not its access modifier (this is especially true for TDD).
  32. PrivateType/PrivateObject use reflection -> slow.If possible (new code or easy/safe refactoring possible), use this strategy instead:change method under test to internalselectively grant access to the test assembly from your tested assemblyrecommended location: AssemblyInfo.csif the tested assembly is strongly signed, the test assembly has to be also and you need to provide the key
  33. Writing a meaningful test normally requires that you isolate the code under test from the rest of the application – if you don‘t do that, then your test may effectively ‚test‘ the entire application (or at least a big portion of it). In such a case, the test has noumerous reasons why it can fail. What exactly is the test really testing then? (This is one of the most common reasons for a test to be almost useless...)This is where the concept of ‚Mocking‘ comes into play.Things you can do with mocking:Create test dummies that can replace the dependencies to other classes which the tested code normally has.Specify return values from your test dummy – specific to certain argument values, if needed.Verify that a certain method was called – again you can check for the method arguments, if you need to.The framework which we will use here is Moq (pron. ‚Mock‘ or ‚MockYou‘)Open SourceVery simple, but not too simple - gives you everything you ever needVery easy to learnMakes heavy use of lambda-syntaxGood documentationThere are many other OS mocking frameworks (even a bit too much for my taste), and the number is still growing...
  34. Example for mocking with Moq: The code to test.
  35. Example for mocking with Moq: The test method (in this case verifies a method call).
  36. The traditional OS mocking frameworks generate transparent runtime proxies which override interface implementations and virtual methods with (initially) empty method stubs. While you should use it where possible (it‘s fast), there are some serious drawbacks (Especially when writing tests for an already existing codebase, where you have no influence on the architectural design):You need to follow the ‚Dependency Injection‘ design principle, otherwise you‘re stuck.You need interfaces and/or virtual methods everywhere.What about static classes (e.g. Helpers, Singletons)?What about .NET framework stuff?All this can‘t be done with traditional mocking. Here we need another framework to the rescue: MS Moles.While at first sight it serves the same purpose as Moq (namely Isolation), it does this with a totally different technology: First you need to create a special assembly (derived from the original assembly under test), which contains stubs (or hooks in C++-speak) for all the original classes members. These stubs then during runtime dynamically replace the class‘original entry points. This is possible because the test is run by a specialized test runner.All this is quite handy, useful and often required, but it comes with significant performance costs...
  37. Create the Moles assembly from your project references...
  38. The name of the Moles assembly is derived from the original name (‚.Moles‘ is added).There is also an xml file and a .Designer file.Add the dll and the xml file to your project, so that they are checked in. Forget about the .Designer file.Declare the type that you want to have stubs for in your test class‘ file (or in AssemblyInfo.cs, if appropriate) with the MoledType assembly-level attribute.Note: Step 1 is not necessary anymore in newer versions of MS Moles.
  39. Tests which use Moles have to declare a special test runner.Moled method name  original method name + argument type name(s)
  40. Data-driven tests with xml file:Create an xml of the form Rows/Row/Argument name(s).
  41. You can then access this data via the TestContext object.Note that you have to declare the data file and it‘s location via additional test method attributes.Oh, and don‘t forget toadd the data file to the project and check it inenable deployment in the *.testsettings file
  42. You can inspect the results in the Test Result Details window...
  43. Data-driven tests via database are very similar. First create a table for the test data (and remember the column names).
  44. Then define the connection string to access the data in one of two ways:Either in the Test Properties tool window where you are assisted by the well-known Visual Studio dialogue for defining a connection stringOr directly in code via the DataSource attribute
  45. Finally, let me give you a short overview on how we can test against the UI. UI testing definitely is the most difficult and demanding hill on the testing landscape: It requires quite some resources on the build server (usually such tests should run in a separate virtual machine).It usually requires the programmer to write an additional object model on top of the code-to-test.UI tests are difficult to automate (sometimes it‘s even impossible).(This is not to say that UI tests are a bad thing. But it‘s definitely not the kind of stuff that you want to begin your testing career with.)In this section:First I‘ll present you another Open Source framework, namely White.Together with the included recorder application, which is an important tool in daily work.The other tool that you need (for inspecting an application‘s UI): UI Spy from MicrosoftLast I‘ll go quickly over a small part of the object model that lies underneath all the UI tests and finally I will show you a test method that uses it.(Afterwards you most likely will be ready for a cup of coffee...)Note to readers: The presentation originally was targeting a WPF desktop application.
  46. The most important facts about the White framework...
  47. The recorder is used to generate C# code from the user‘s UI actions...
  48. UI Spy is very similar to Spy++, but for .NET/WPF.Used to inspect a UI‘s control structure/properties.Free download, included with the Windows SDK 6.0 (mind the correct version).
  49. This is a small portion of the object model that was written for the UI tests.It is used to have a high-level facade on top of the application‘s UI-relating code.
  50. Test code, pt. 1...
  51. Test code, pt. 2:An actual test method.You can immediately see that things aren‘t that simple here anymore and that there lies a quite huge helper class library underneath this test.
  52. Questions?Concerns?Or only a desperate need for coffee?