SlideShare a Scribd company logo
1 of 23
TestApi A library of testing types,  data-structures and algorithms Ivo Manolov, Microsoft
Sharing of {Test} Code is GOOD Reduced duplication of effort Higher code quality - through evolution Lower maintenance costs Deeper, more mature coverage Etc, etc, etc(see your favorite book on code reuse) 2
Sharing of Tests is TRICKY Need to “adapt” tests to environment Test environment dictates policy… Discovery Deployment / Distribution Execution Logging Reporting Result aggregation and reporting 3
Sharing of Tools is TRICKY Big tools / infrastructure High adoption cost “Proprietary” stack – extension may be tricky “Hosting” costs Deployment on dev machines is frowned upon Combining tool parts may not be supported Small tools (e.g. PICT.EXE, RADAR): Deployment Cleanup Adaptation (of input / output) Upgrades SLAs 4
Well, what CAN we share? Automated tests ARE programs A Program =  		reusable blocks+  		domain-specific logic + config We can share the blocks! 5
Enter TestApi… 6
TestApi is… An API library Provides data-structures and algorithms common to testing Documented Layered Easy to deploy (xcopy) Policy-free It’s just a set of DLLs you link to We have xUnit, NUnit, MSTEST samples Licensed under Ms-PL (shared source) 7
TestApi is notgoing to… tell you what a test is tell you how to test make a test pass/fail decision for you tell you how to log make implicit assumptions integrate with your tools (VS, Eclipse, etc.) retain execution state 8
A Lap Around TestApi 9
Package http://codeplex.com/testapi The ZIP contains… Binaries Sources Documentation Samples 10
Input Simulation API Mouse.MoveTo(new Point(10, 10)); Mouse.Click(MouseButton.Left); Keyboard.Type("Hello world!"); Keyboard.Press(Key.LeftShift); Keyboard.Type("hello, capitalized world!"); Keyboard.Release(Key.LeftShift); 11 Mouse and Keyboard are wrappers of the SendInput Win32 API.  They are GUI-toolkit-agnostic (Mouse works in screen coordinates, etc.)
Visual Verification API // Take a snapshot of a window. Load a snapshot from disk. Compare. Snapshot actual = Snapshot.FromWindow(hwnd, WindowSnapshotMode.ExcludeWindowBorder); Snapshot expected = Snapshot.FromFile("Expected.png"); Snapshot difference = actual.CompareTo(expected); // Initialize a SnapshotVerifier and use it to verify the difference image Snapshot toleranceMap = Snapshot.FromFile("ExpectedImageToleranceMap.png"); SnapshotVerifier verifier = new SnapshotToleranceMapVerifier(toleranceMap); if (verifier.Verify(difference) == VerificationResult.Fail) { actual.ToFile("Actual.png", ImageFormat.Png); difference.ToFile("Difference.png", ImageFormat.Png); Console.WriteLine("Image mismatch!"); } 12 The API provides different visual verification strategies via different SnapshotVerifiers
Variation Generation API Define a set of named parameters and constraints. var destination = new Parameter<string>("Destination") { "Whistler", "Las Vegas" }; varhotelQuality = new Parameter<int>("Hotel Quality") { 5, 4, 3, 2, 1 };  var activity = new Parameter<string>("Activity") { "gambling", "swimming", "skiing" }; var parameters = new List<ParameterBase> { destination, hotelQuality, activity}; var constraints = new List<Constraint<Variation>> { Constraint<Variation>        .If(v => destination.GetValue(v) == "Las Vegas")        .Then(v => activity.GetValue(v) != "skiing"),     ... }; Modelmodel = new Model(parameters, constraints); foreach(varv in model.GenerateVariations(2, 1234)) { Console.WriteLine("{0} {1} {2}",          v["Destination"], v["Hotel Quality"], v["Activity"]); } Create a model from them. Then query the model for variations. 13
Variation Generation API - 2 14 // Need to go to Cleveland more often... object tag = (object)-1; double weight = 5.0; var destination =      new Parameter<string>("Destination")      {          "Whistler",          "Hawaii",          "Las Vegas",         new ParameterValue<string>("Cleveland", tag, weight)     }; ... foreach(var v in model.GenerateVariations(2, 1234)) {     switch (v.Tag as int) {...} } Parameter value weights are also supported. Parameter value tags provide a generic support for “negative” variations, etc.
Variation Generation API - 3 class OsConfiguration { [Parameter(512, 1024, 2048)]   public int Memory { get; set; } [Parameter("WinXP")]   [Parameter("Vista", "Win7", Weight = 3.0F)]    public string OS { get; set; } } static void CreateModel() { var model = new Model<OsConfiguration>(); foreach(OsConfigurationc in model.GenerateVariations(2))    { Console.WriteLine(         "{0} {1}",  c.Memory,  c.OS); } 15 Models can also be constructed declaratively.  The declarative syntax supports equivalence classes and weights too.
Fault Injection API string caller = "MyApp.Main(string[])" string method = "MyApp.PrintToConsole(string)"; Exception exception = new ApplicationException("Injected!")); // Create a set of fault rules ICondition condition = BuiltInConditions.TriggerIfCalledBy(caller); IFault fault = BuiltInFaults.ThrowExceptionFault(exception); FaultRule rule = new FaultRule(method, condition, fault); // Establish a session, injecting faults defined by the rules FaultSession session = new FaultSession(rule); // Launch the target process. Observe faults. ProcessStartInfo psi = session.GetProcessStartInfo(@"yApp.exe"); Process p = Process.Start(psi); ... Under the cover, TestApi uses the CLR profiling API to modify the prologue of the intercepted method at runtime… 16
Memory Leak Detection API // Start your process... // Perform various operations. Take memory snapshots MemorySnapshot s1 = MemorySnapshot.FromProcess(pid); ... MemorySnapshot s2 = MemorySnapshot.FromProcess(pid); // Compare snapshots. Identify possible leaks. MemorySnapshot diff = s2.CompareTo(s1); if (diff.GdiObjectCount != 0) {     s1.ToFile(@"1.xml");     s2.ToFile(@"2.xml"); Console.WriteLine("Possible GDI handle leak."); } 17
Text Generation API StringProperties sp = new StringProperties(); sp.UnicodeRanges.Add(new UnicodeRange(0x0400, 0x04FF)); sp.MinNumberOfCodePoints = sp.MaxNumberOfCodePoints = 10; string s = StringFactory.GenerateRandomString(sp, 1234); The result would be a string of 10 characters in the Cyrillic Unicode character code range, e.g. … “хѝЗКтТшщчЯ” 18
Object Comparison API // o1 and o2 are arbitrarily complex objects... ObjectGraphFactory f = new PublicPropertyObjectGraphFactory(); ObjectComparer c = new ObjectComparer(f);   bool match = c.Compare(o1, o2); if (!match) { Console.WriteLine("The two objects do not match."); }   // you can also get a collection of mismatches... bool match = c.Compare(o1, o2, out mismatches); ... For custom comparison  strategies, create your own ObjectGraphFactory. ObjectComparisonMismatch instances. 19
Application Control API var a = new OutOfProcessApplication(     new OutOfProcessApplicationSettings     {  ProcessStartInfo = new ProcessStartInfo(path),  ApplicationImplementationFactory =              new UIAutomationOutOfProcessApplicationFactory()      });  a.Start();  a.WaitForMainWindow(TimeSpan.FromMilliseconds(5000));  // Perform various tests...  a.Close(); The API provides both in-proc and out-of-proc application control capabilities for arbitrary applications (you may need to write your own factories) 20
Command-Line Parsing API // Example 1:  // Parse "test.exe /verbose /runId=10"  CommandLineDictionary d =  CommandLineDictionary.FromArguments(args) bool verbose = d.ContainsKey("verbose"); inttestId = Int32.Parse(d["testId"]); // Example 2: // Parse the same into a structure public class MyArguments { public bool? Verbose { get; set; } public int? RunId { get; set; } } MyArguments a = new MyArguments(); CommandLineParser.ParseArguments(a, args); There is also a 3rd layer, which provides capability to parse into type-safe commands to support usages such as  “Test.exe run /runId=10 /verbose” 21
In Closing… TestApi enables code reuse at the building block level. Think of it as a testing BCL. Democratic use of facilities – no strings attached Layered, decoupled Public Get Engaged! http://codeplex.com/testapi testapi@microsoft.com 22
Q & A ? 23

More Related Content

What's hot

Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST APIIvan Katunou
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login applicationSomkiat Puisungnoen
 
Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOASYoann Buch
 
Finally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersFinally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersRudy De Busscher
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An IntroductionSam Brannen
 
Developer Tutorial: WebAuthn for Web & FIDO2 for Android
Developer Tutorial: WebAuthn for Web & FIDO2 for AndroidDeveloper Tutorial: WebAuthn for Web & FIDO2 for Android
Developer Tutorial: WebAuthn for Web & FIDO2 for AndroidFIDO Alliance
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - IntroductionKnoldus Inc.
 
Allure framework. Пример настройки исчерпывающего репорта на реальном проекте
Allure framework. Пример настройки исчерпывающего репорта на реальном проектеAllure framework. Пример настройки исчерпывающего репорта на реальном проекте
Allure framework. Пример настройки исчерпывающего репорта на реальном проектеCOMAQA.BY
 
Automação e virtualização de serviços
Automação e virtualização de serviçosAutomação e virtualização de serviços
Automação e virtualização de serviçosElias Nogueira
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_PostmanMithilesh Singh
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST AssuredTO THE NEW Pvt. Ltd.
 

What's hot (20)

Test Design and Automation for REST API
Test Design and Automation for REST APITest Design and Automation for REST API
Test Design and Automation for REST API
 
Robot Framework
Robot FrameworkRobot Framework
Robot Framework
 
Robot Framework :: Demo login application
Robot Framework :: Demo login applicationRobot Framework :: Demo login application
Robot Framework :: Demo login application
 
Belajar Postman test runner
Belajar Postman test runnerBelajar Postman test runner
Belajar Postman test runner
 
Spring HATEOAS
Spring HATEOASSpring HATEOAS
Spring HATEOAS
 
Finally, easy integration testing with Testcontainers
Finally, easy integration testing with TestcontainersFinally, easy integration testing with Testcontainers
Finally, easy integration testing with Testcontainers
 
Testing with Spring: An Introduction
Testing with Spring: An IntroductionTesting with Spring: An Introduction
Testing with Spring: An Introduction
 
Developer Tutorial: WebAuthn for Web & FIDO2 for Android
Developer Tutorial: WebAuthn for Web & FIDO2 for AndroidDeveloper Tutorial: WebAuthn for Web & FIDO2 for Android
Developer Tutorial: WebAuthn for Web & FIDO2 for Android
 
Robot framework
Robot frameworkRobot framework
Robot framework
 
OAuth2 - Introduction
OAuth2 - IntroductionOAuth2 - Introduction
OAuth2 - Introduction
 
Allure framework. Пример настройки исчерпывающего репорта на реальном проекте
Allure framework. Пример настройки исчерпывающего репорта на реальном проектеAllure framework. Пример настройки исчерпывающего репорта на реальном проекте
Allure framework. Пример настройки исчерпывающего репорта на реальном проекте
 
PHPUnit - Unit testing
PHPUnit - Unit testingPHPUnit - Unit testing
PHPUnit - Unit testing
 
Automação e virtualização de serviços
Automação e virtualização de serviçosAutomação e virtualização de serviços
Automação e virtualização de serviços
 
Api testing
Api testingApi testing
Api testing
 
API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0API Docs with OpenAPI 3.0
API Docs with OpenAPI 3.0
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 
API_Testing_with_Postman
API_Testing_with_PostmanAPI_Testing_with_Postman
API_Testing_with_Postman
 
Rest API Automation with REST Assured
Rest API Automation with REST AssuredRest API Automation with REST Assured
Rest API Automation with REST Assured
 
Robot framework and selenium2 library
Robot framework and selenium2 libraryRobot framework and selenium2 library
Robot framework and selenium2 library
 
Api Testing
Api TestingApi Testing
Api Testing
 

Viewers also liked

How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API TestingBruno Pedro
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonTEST Huddle
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Data Driven API Testing: Best Practices for Real-World Testing Scenarios
Data Driven API Testing: Best Practices for Real-World Testing ScenariosData Driven API Testing: Best Practices for Real-World Testing Scenarios
Data Driven API Testing: Best Practices for Real-World Testing ScenariosSmartBear
 
4 Major Advantages of API Testing
4 Major Advantages of API Testing4 Major Advantages of API Testing
4 Major Advantages of API TestingQASource
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIsSmartBear
 
Testing APIs in the Cloud
Testing APIs in the CloudTesting APIs in the Cloud
Testing APIs in the CloudSmartBear
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Bitbar
 
Bohomolets Microbiology Lecture #18
Bohomolets Microbiology Lecture #18Bohomolets Microbiology Lecture #18
Bohomolets Microbiology Lecture #18Dr. Rubz
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Bitbar
 
Frisby: Rest API Automation Framework
Frisby: Rest API Automation FrameworkFrisby: Rest API Automation Framework
Frisby: Rest API Automation FrameworkQuovantis
 
Web API Test Automation using Frisby & Node.js
Web API Test Automation using Frisby  & Node.jsWeb API Test Automation using Frisby  & Node.js
Web API Test Automation using Frisby & Node.jsChi Lang Le Vu Tran
 
The Progression of APIs and Microservices - Photon Infotech
The Progression of APIs and Microservices - Photon InfotechThe Progression of APIs and Microservices - Photon Infotech
The Progression of APIs and Microservices - Photon InfotechPhoton
 
Testing web services
Testing web servicesTesting web services
Testing web servicesTaras Lytvyn
 

Viewers also liked (19)

How to Automate API Testing
How to Automate API TestingHow to Automate API Testing
How to Automate API Testing
 
API Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj RollisonAPI Testing: The heart of functional testing" with Bj Rollison
API Testing: The heart of functional testing" with Bj Rollison
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
API Testing
API TestingAPI Testing
API Testing
 
Data Driven API Testing: Best Practices for Real-World Testing Scenarios
Data Driven API Testing: Best Practices for Real-World Testing ScenariosData Driven API Testing: Best Practices for Real-World Testing Scenarios
Data Driven API Testing: Best Practices for Real-World Testing Scenarios
 
Api testing
Api testingApi testing
Api testing
 
4 Major Advantages of API Testing
4 Major Advantages of API Testing4 Major Advantages of API Testing
4 Major Advantages of API Testing
 
Evaluating and Testing Web APIs
Evaluating and Testing Web APIsEvaluating and Testing Web APIs
Evaluating and Testing Web APIs
 
Testing APIs in the Cloud
Testing APIs in the CloudTesting APIs in the Cloud
Testing APIs in the Cloud
 
Android Test Automation Workshop
Android Test Automation WorkshopAndroid Test Automation Workshop
Android Test Automation Workshop
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Bohomolets Microbiology Lecture #18
Bohomolets Microbiology Lecture #18Bohomolets Microbiology Lecture #18
Bohomolets Microbiology Lecture #18
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?Different Android Test Automation Frameworks - What Works You the Best?
Different Android Test Automation Frameworks - What Works You the Best?
 
Frisby: Rest API Automation Framework
Frisby: Rest API Automation FrameworkFrisby: Rest API Automation Framework
Frisby: Rest API Automation Framework
 
Web API Test Automation using Frisby & Node.js
Web API Test Automation using Frisby  & Node.jsWeb API Test Automation using Frisby  & Node.js
Web API Test Automation using Frisby & Node.js
 
The Progression of APIs and Microservices - Photon Infotech
The Progression of APIs and Microservices - Photon InfotechThe Progression of APIs and Microservices - Photon Infotech
The Progression of APIs and Microservices - Photon Infotech
 
Salmonella
SalmonellaSalmonella
Salmonella
 
Testing web services
Testing web servicesTesting web services
Testing web services
 

Similar to Test api

Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaDenilson Nastacio
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework OverviewMario Peshev
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsKai Cui
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEBenjamin Cabé
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfoliomwillmer
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanizecoreygoldberg
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSKnoldus Inc.
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsPVS-Studio
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web developmentalice yang
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgePVS-Studio
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answersRita Singh
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioAndrey Karpov
 
Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Azhar Satti
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testingpleeps
 
E catt tutorial
E catt tutorialE catt tutorial
E catt tutorialNaveen Raj
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingVisual Engineering
 

Similar to Test api (20)

Mastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for JavaMastering Mock Objects - Advanced Unit Testing for Java
Mastering Mock Objects - Advanced Unit Testing for Java
 
Oleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoCOleksandr Valetskyy - DI vs. IoC
Oleksandr Valetskyy - DI vs. IoC
 
JMockit Framework Overview
JMockit Framework OverviewJMockit Framework Overview
JMockit Framework Overview
 
Compatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensionsCompatibility Detector Tool of Chrome extensions
Compatibility Detector Tool of Chrome extensions
 
Use Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDEUse Eclipse technologies to build a modern embedded IDE
Use Eclipse technologies to build a modern embedded IDE
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
.NET Portfolio
.NET Portfolio.NET Portfolio
.NET Portfolio
 
Tdd,Ioc
Tdd,IocTdd,Ioc
Tdd,Ioc
 
Performance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-MechanizePerformance and Scalability Testing with Python and Multi-Mechanize
Performance and Scalability Testing with Python and Multi-Mechanize
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Analysis of Microsoft Code Contracts
Analysis of Microsoft Code ContractsAnalysis of Microsoft Code Contracts
Analysis of Microsoft Code Contracts
 
Test strategy for web development
Test strategy for web developmentTest strategy for web development
Test strategy for web development
 
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft EdgeChakraCore: analysis of JavaScript-engine for Microsoft Edge
ChakraCore: analysis of JavaScript-engine for Microsoft Edge
 
QTP Interview Questions and answers
QTP Interview Questions and answersQTP Interview Questions and answers
QTP Interview Questions and answers
 
Checking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-StudioChecking Clang 11 with PVS-Studio
Checking Clang 11 with PVS-Studio
 
Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256Qtp Training Deepti 3 Of 44256
Qtp Training Deepti 3 Of 44256
 
Qtp Training
Qtp Training Qtp Training
Qtp Training
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
E catt tutorial
E catt tutorialE catt tutorial
E catt tutorial
 
Workshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testingWorkshop 23: ReactJS, React & Redux testing
Workshop 23: ReactJS, React & Redux testing
 

Recently uploaded

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 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
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 

Recently uploaded (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

Test api

  • 1. TestApi A library of testing types, data-structures and algorithms Ivo Manolov, Microsoft
  • 2. Sharing of {Test} Code is GOOD Reduced duplication of effort Higher code quality - through evolution Lower maintenance costs Deeper, more mature coverage Etc, etc, etc(see your favorite book on code reuse) 2
  • 3. Sharing of Tests is TRICKY Need to “adapt” tests to environment Test environment dictates policy… Discovery Deployment / Distribution Execution Logging Reporting Result aggregation and reporting 3
  • 4. Sharing of Tools is TRICKY Big tools / infrastructure High adoption cost “Proprietary” stack – extension may be tricky “Hosting” costs Deployment on dev machines is frowned upon Combining tool parts may not be supported Small tools (e.g. PICT.EXE, RADAR): Deployment Cleanup Adaptation (of input / output) Upgrades SLAs 4
  • 5. Well, what CAN we share? Automated tests ARE programs A Program = reusable blocks+ domain-specific logic + config We can share the blocks! 5
  • 7. TestApi is… An API library Provides data-structures and algorithms common to testing Documented Layered Easy to deploy (xcopy) Policy-free It’s just a set of DLLs you link to We have xUnit, NUnit, MSTEST samples Licensed under Ms-PL (shared source) 7
  • 8. TestApi is notgoing to… tell you what a test is tell you how to test make a test pass/fail decision for you tell you how to log make implicit assumptions integrate with your tools (VS, Eclipse, etc.) retain execution state 8
  • 9. A Lap Around TestApi 9
  • 10. Package http://codeplex.com/testapi The ZIP contains… Binaries Sources Documentation Samples 10
  • 11. Input Simulation API Mouse.MoveTo(new Point(10, 10)); Mouse.Click(MouseButton.Left); Keyboard.Type("Hello world!"); Keyboard.Press(Key.LeftShift); Keyboard.Type("hello, capitalized world!"); Keyboard.Release(Key.LeftShift); 11 Mouse and Keyboard are wrappers of the SendInput Win32 API. They are GUI-toolkit-agnostic (Mouse works in screen coordinates, etc.)
  • 12. Visual Verification API // Take a snapshot of a window. Load a snapshot from disk. Compare. Snapshot actual = Snapshot.FromWindow(hwnd, WindowSnapshotMode.ExcludeWindowBorder); Snapshot expected = Snapshot.FromFile("Expected.png"); Snapshot difference = actual.CompareTo(expected); // Initialize a SnapshotVerifier and use it to verify the difference image Snapshot toleranceMap = Snapshot.FromFile("ExpectedImageToleranceMap.png"); SnapshotVerifier verifier = new SnapshotToleranceMapVerifier(toleranceMap); if (verifier.Verify(difference) == VerificationResult.Fail) { actual.ToFile("Actual.png", ImageFormat.Png); difference.ToFile("Difference.png", ImageFormat.Png); Console.WriteLine("Image mismatch!"); } 12 The API provides different visual verification strategies via different SnapshotVerifiers
  • 13. Variation Generation API Define a set of named parameters and constraints. var destination = new Parameter<string>("Destination") { "Whistler", "Las Vegas" }; varhotelQuality = new Parameter<int>("Hotel Quality") { 5, 4, 3, 2, 1 }; var activity = new Parameter<string>("Activity") { "gambling", "swimming", "skiing" }; var parameters = new List<ParameterBase> { destination, hotelQuality, activity}; var constraints = new List<Constraint<Variation>> { Constraint<Variation> .If(v => destination.GetValue(v) == "Las Vegas") .Then(v => activity.GetValue(v) != "skiing"), ... }; Modelmodel = new Model(parameters, constraints); foreach(varv in model.GenerateVariations(2, 1234)) { Console.WriteLine("{0} {1} {2}", v["Destination"], v["Hotel Quality"], v["Activity"]); } Create a model from them. Then query the model for variations. 13
  • 14. Variation Generation API - 2 14 // Need to go to Cleveland more often... object tag = (object)-1; double weight = 5.0; var destination = new Parameter<string>("Destination") { "Whistler", "Hawaii", "Las Vegas", new ParameterValue<string>("Cleveland", tag, weight) }; ... foreach(var v in model.GenerateVariations(2, 1234)) { switch (v.Tag as int) {...} } Parameter value weights are also supported. Parameter value tags provide a generic support for “negative” variations, etc.
  • 15. Variation Generation API - 3 class OsConfiguration { [Parameter(512, 1024, 2048)] public int Memory { get; set; } [Parameter("WinXP")] [Parameter("Vista", "Win7", Weight = 3.0F)] public string OS { get; set; } } static void CreateModel() { var model = new Model<OsConfiguration>(); foreach(OsConfigurationc in model.GenerateVariations(2)) { Console.WriteLine( "{0} {1}", c.Memory, c.OS); } 15 Models can also be constructed declaratively. The declarative syntax supports equivalence classes and weights too.
  • 16. Fault Injection API string caller = "MyApp.Main(string[])" string method = "MyApp.PrintToConsole(string)"; Exception exception = new ApplicationException("Injected!")); // Create a set of fault rules ICondition condition = BuiltInConditions.TriggerIfCalledBy(caller); IFault fault = BuiltInFaults.ThrowExceptionFault(exception); FaultRule rule = new FaultRule(method, condition, fault); // Establish a session, injecting faults defined by the rules FaultSession session = new FaultSession(rule); // Launch the target process. Observe faults. ProcessStartInfo psi = session.GetProcessStartInfo(@"yApp.exe"); Process p = Process.Start(psi); ... Under the cover, TestApi uses the CLR profiling API to modify the prologue of the intercepted method at runtime… 16
  • 17. Memory Leak Detection API // Start your process... // Perform various operations. Take memory snapshots MemorySnapshot s1 = MemorySnapshot.FromProcess(pid); ... MemorySnapshot s2 = MemorySnapshot.FromProcess(pid); // Compare snapshots. Identify possible leaks. MemorySnapshot diff = s2.CompareTo(s1); if (diff.GdiObjectCount != 0) { s1.ToFile(@"1.xml"); s2.ToFile(@"2.xml"); Console.WriteLine("Possible GDI handle leak."); } 17
  • 18. Text Generation API StringProperties sp = new StringProperties(); sp.UnicodeRanges.Add(new UnicodeRange(0x0400, 0x04FF)); sp.MinNumberOfCodePoints = sp.MaxNumberOfCodePoints = 10; string s = StringFactory.GenerateRandomString(sp, 1234); The result would be a string of 10 characters in the Cyrillic Unicode character code range, e.g. … “хѝЗКтТшщчЯ” 18
  • 19. Object Comparison API // o1 and o2 are arbitrarily complex objects... ObjectGraphFactory f = new PublicPropertyObjectGraphFactory(); ObjectComparer c = new ObjectComparer(f);   bool match = c.Compare(o1, o2); if (!match) { Console.WriteLine("The two objects do not match."); }   // you can also get a collection of mismatches... bool match = c.Compare(o1, o2, out mismatches); ... For custom comparison strategies, create your own ObjectGraphFactory. ObjectComparisonMismatch instances. 19
  • 20. Application Control API var a = new OutOfProcessApplication( new OutOfProcessApplicationSettings { ProcessStartInfo = new ProcessStartInfo(path), ApplicationImplementationFactory = new UIAutomationOutOfProcessApplicationFactory() }); a.Start(); a.WaitForMainWindow(TimeSpan.FromMilliseconds(5000)); // Perform various tests... a.Close(); The API provides both in-proc and out-of-proc application control capabilities for arbitrary applications (you may need to write your own factories) 20
  • 21. Command-Line Parsing API // Example 1: // Parse "test.exe /verbose /runId=10" CommandLineDictionary d = CommandLineDictionary.FromArguments(args) bool verbose = d.ContainsKey("verbose"); inttestId = Int32.Parse(d["testId"]); // Example 2: // Parse the same into a structure public class MyArguments { public bool? Verbose { get; set; } public int? RunId { get; set; } } MyArguments a = new MyArguments(); CommandLineParser.ParseArguments(a, args); There is also a 3rd layer, which provides capability to parse into type-safe commands to support usages such as “Test.exe run /runId=10 /verbose” 21
  • 22. In Closing… TestApi enables code reuse at the building block level. Think of it as a testing BCL. Democratic use of facilities – no strings attached Layered, decoupled Public Get Engaged! http://codeplex.com/testapi testapi@microsoft.com 22
  • 23. Q & A ? 23

Editor's Notes

  1. Sharing of test code is tricky.If you attempt to share tests, you have to adapt the tests you share to the target test run environment, which is not tricky
  2. The input simulation API provides a simple way to simulate input.The input API wrap the SendInput Win32 API under the covers.
  3. The fundamental premise of visual verification is comparing an expected image (either a master image loaded from file or a generated image) to an actual image and making a pass/fail decision based on the result from the comparison.The Snapshot class allows you to take snapshots of the screen, load snapshots from disk and compare the current Snapshot instance to another instance (generating a diff).The API also provides a family of verifiers (they all inherit from SnapshotVerifier), which use different strategies to perform verification of (most commonly a diff) Snapshot instance.
  4. Note that the API also supports weighted parameters as well as “tagged parameter values” for negative testing, etc.
  5. Of course, we support
  6. Fault injection is a code coverage technique that allows you to change the behavior of a program.TestApi provides a simple mechanism for injecting of faults in managed code at run-time.
  7. The MemorySnapshot class provides an easy way to take memory snapshots of a running process (or load saved snapshots from disk).The generated memory snapshots track all main memory metrics of a process:GdiObjectCountHandleCountPageFileBytesPageFilePeakBytesPoolNonpagedBytesPoolPagedBytesThreadCountTimestampUserObjectCountVirtualMemoryBytesVirtualMemoryPrivateBytesWorkingSetBytesWorkingSetPeakBytesWorkingSetPrivateBytes
  8. ObjectComparer is a sealed class (cannot be extended)ObjectGraphFactory is an abstract class, with a single virtual method CreateObjectGraph, which returns a GraphNode instance representing the root node of the created graph.ObjectComparisonMismatch instances have LeftObjectNode, RightObjectNode and MismatchType members.
  9. For more, see http://blogs.msdn.com/ivo_manolov/archive/2008/12/17/9230331.aspx