SlideShare ist ein Scribd-Unternehmen logo
1 von 30
Automated testing of EPiServer CMS sitesAn overview of testing in general and specifically EPiServer sites
About me Joel Abrahamsson Living in Stockholm Works at Valtech Develops websites with ASP.NET and EPiServer Blogs about web development Founder of the open source projects Page Type Builder, EPiAbstractions and co-founder of EPiMVP
Agenda The importance of automation Types of testing xUnit testing Isolating code Challenges when testing EPiServer sites
The importance of automation Quick feedback loops Less debugging Limits the human factor Documentation
Automation goals We want our tests to be run. Often. By everyone. Tests should be self-checking Tests should be repeatable Tests should be independent of environment Tests should run fast There should be no hassle running our tests.
Types of automated tests UI Tests Integration tests Unit tests
UI Testing Tests all layers of the application Frameworks Selenium Watin/Watir Can be run using a GUIor as part of xUnit tests Pros Concrete/easy to understand Easy to get started Cons Very slow Hard to maintain Blunt feedback Use for a few key scenarios or when refactoring for testability Write maintainable tests using Page Objects User interface Business logic Data access Database
Tests several layers of the application Implemented using Xunit frameworks Pros No isolation required Ensures that whole features work Cons Slow Doesn’t give very accurate feedback Hard to maintain and set up Use to verify functionality of interactions Don’t confuse with unit tests Integration Testing User interface Business logic Data access Database
Tests individual units in the system Implemented using Xunit frameworks Pros Fast Precise feedback Can be used to drive developmentand ensure good design Cons Requires isolation/mocking Use to drive development to ensure good design and provide documentation Write tests for design and documentation, not quality assurance Unit Testing User interface Business logic Data access Database
The common name for a set of code-driven testing frameworks Test Fixtures Test Suites Assertions Test consists of four phases Set up Exercise Verify Tear down xUnit
The verification phase consists of one or several assertions Tests either test state or interactions Verifying state means checking a returned value or ensuring that an object is in a specific state Verifying interactions usually means verifying that the component being tested has performed an interaction with another component.  xUnit - Asserts
Frameworks NUnit MBUnit xUnit.net Visual Studio Unit Testing Framework / MSTest Executed using test runners on clients and by build servers Many frameworks comes with built in runners Resharper TestDriven.NET xUnit Frameworks
Replace a depency with a different component with the same interface to enable and verify interactions Also known as mocking Accomplished using Inversion of Control Replacing interface methods or virtual methods Frameworks Rhino Mocks Moq Isolator NUnit.Mocks Code Isolation
Allow a consumer to consume a component without knowing the specifics and origins of the component in advance Implement using Dependency Injection or Service Locator Inversion of Control
Inversion of Control – An example
Using IoC leads to flexible components Using IoC helps us conform to the SOLID principles  The Dependency Inversion Principle - Depend on abstractions, not on concretions The Single Responsibility Principle - A class should have one, and only one, reason to change IoC leads to good design
The consumer of the consumer provides the consumer with the component it depends upon Constructor Injection Property Injection Dependency Injection
The consumer retrieves the component it depends upon from a third party, a Service Locator Use Dependency Injection instead if you can Service Locator
Frameworks for managing dependencies Enable life cycle aware applications A wide range of open source frameworks StructureMap Ninject Unity Castle Windsor Autofac IoC Containers
Test Doubles Dummies – objects that are passed around but never used. Fakes – Working implementations Stubs – Provides implementations for certain methods with responses defined in the test Mocks – Same as stubs but with expectations that can be verified Partial mocks Isolation/Mocking terminology
Static or non-virtual methods Example: all methods in DataFactory are non-virtual Makes Inversion of Control hard Dependent on it’s configuration Makes it hard to test single units of code Tightly integrated with Web Forms Makes it hard to test without a HTTP Context Complicates Depency Injection EPiServer CMS challenges
Create wrappers EPiAbstractions epiabstractions.codeplex.com Beware of security concerns Overcoming static and non-virtual methods
Create wrappers Use Page Type Builder to decouple from PageData.Property Partial mocking Overcoming dependencies on the configuration
Extract business logic from pages and controls Use Page Type Builder to decouple from PageData.Property pagetypebuilder.codeplex.com The Model View Presenter pattern Web Forms MVP webformsmvp.com EPiMVP github.com/joelabrahamsson/EPiServer-MVP Overcoming tight Web Forms integration
Model View Presenter Image from http://geekswithblogs.net/dchristiansen/archive/2007/12/07/microsoft-patterns-and-practices-team-release-the-model-view-presenter.aspx
Two base classes for pages and controls, EPiMvpPage and EPiMvpUserControl A base class for presenters, EPiPresenter A presenterfactory that instantiates presenters for views with the view and PageData object Also comes with two presenterfactories that utilizes IoC containers, StructureMap and Ninject EPiMVP - Components
A request comes in to the view Web Forms MVP inspects the views PresenterBinding attribute to find the presenter type Web Forms MVP uses a configured (in global.asax) PresenterFactory to instantiate a presenter with a modelobject The presenter, which receives the view and PageData object in the constructor attaches it’s methods to the view’s events EPiMVP – How it works
Good candidates for testing include Integrations with external services Utilities (AddQuerystringParameter etc) Custom caching Components that easily get to be complex (example: paging) Bad candidates include Components with extremely little logic Components where the logic is handled by EPiServer (menus etc) Components that deal with, or are closely coupled to, markup  Keep in mind that the point of the test isn’t only what it tests but that it drives good design What to (not) test using unit tests
Give your tests descriptive names Care about the code in your test Arrange your tests using AAA (Arrange, Act, Assert) Also known as Given-When-Then Be carefull with using code coverage as a measurement Some principles such as the DRY principle isn’t always valid for tests Do not use tools to generate tests. Period. Words of advice
Questions? http://joelabrahamsson.com @joelabrahamsson mail@joelabrahamsson.com

Weitere ähnliche Inhalte

Was ist angesagt?

Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101Rich Helton
 
Benefits of the CodeIgniter Framework
Benefits of the CodeIgniter FrameworkBenefits of the CodeIgniter Framework
Benefits of the CodeIgniter FrameworkToby Beresford
 
Selenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and TricksSelenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and TricksEdureka!
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Netvidyamittal
 
Play framework : A Walkthrough
Play framework : A WalkthroughPlay framework : A Walkthrough
Play framework : A Walkthroughmitesh_sharma
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011hugs
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
Automated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDEAutomated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDERobert Greiner
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Gunith Devasurendra
 
Web application development using zend framework
Web application development using zend frameworkWeb application development using zend framework
Web application development using zend frameworkSayed Ahmed
 
Azure providers - Bouvet BigOne 2011
Azure providers - Bouvet BigOne 2011Azure providers - Bouvet BigOne 2011
Azure providers - Bouvet BigOne 2011Inge Henriksen
 

Was ist angesagt? (20)

Advanced Java
Advanced JavaAdvanced Java
Advanced Java
 
Entity frameworks101
Entity frameworks101Entity frameworks101
Entity frameworks101
 
IIS 6.0 and asp.net
IIS 6.0 and asp.netIIS 6.0 and asp.net
IIS 6.0 and asp.net
 
Background processing with hangfire
Background processing with hangfireBackground processing with hangfire
Background processing with hangfire
 
Benefits of the CodeIgniter Framework
Benefits of the CodeIgniter FrameworkBenefits of the CodeIgniter Framework
Benefits of the CodeIgniter Framework
 
Selenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and TricksSelenium WebDriver: Tips and Tricks
Selenium WebDriver: Tips and Tricks
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
Concepts of Asp.Net
Concepts of Asp.NetConcepts of Asp.Net
Concepts of Asp.Net
 
Play framework : A Walkthrough
Play framework : A WalkthroughPlay framework : A Walkthrough
Play framework : A Walkthrough
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
Selenium Webdriver
Selenium WebdriverSelenium Webdriver
Selenium Webdriver
 
Azure rev002
Azure rev002Azure rev002
Azure rev002
 
Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011Selenium 2 - PyCon 2011
Selenium 2 - PyCon 2011
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
Automated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDEAutomated Testing for Websites With Selenium IDE
Automated Testing for Websites With Selenium IDE
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Web application development using zend framework
Web application development using zend frameworkWeb application development using zend framework
Web application development using zend framework
 
Azure providers - Bouvet BigOne 2011
Azure providers - Bouvet BigOne 2011Azure providers - Bouvet BigOne 2011
Azure providers - Bouvet BigOne 2011
 

Ähnlich wie Automated Testing Of EPiServer CMS Sites

Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Kevin Schultz
 
What is Selenium Testing.pdf
What is Selenium Testing.pdfWhat is Selenium Testing.pdf
What is Selenium Testing.pdfAnanthReddy38
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfMinh Quân Đoàn
 
No More No Repro
No More No ReproNo More No Repro
No More No ReproAnna Russo
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With SeleniumJodie Miners
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing FundamentalsRichard Paul
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Seleniumvivek_prahlad
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Steve Lange
 
Overview of Lab Management and TFS
Overview of Lab Management and TFSOverview of Lab Management and TFS
Overview of Lab Management and TFSChris Kadel, MBA
 
Presentation 1 open source tools in continuous integration environment v1.0
Presentation 1   open source tools in continuous integration environment v1.0Presentation 1   open source tools in continuous integration environment v1.0
Presentation 1 open source tools in continuous integration environment v1.0Jasmine Conseil
 
Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScriptSimon Guest
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Joe Ferguson
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0Shiju Varghese
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework DesignsSauce Labs
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Joe Ferguson
 

Ähnlich wie Automated Testing Of EPiServer CMS Sites (20)

Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)Building Maintainable Android Apps (DroidCon NYC 2014)
Building Maintainable Android Apps (DroidCon NYC 2014)
 
What is Selenium Testing.pdf
What is Selenium Testing.pdfWhat is Selenium Testing.pdf
What is Selenium Testing.pdf
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
 
No More No Repro
No More No ReproNo More No Repro
No More No Repro
 
Automated Web Testing With Selenium
Automated Web Testing With SeleniumAutomated Web Testing With Selenium
Automated Web Testing With Selenium
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)Whats New In 2010 (Msdn & Visual Studio)
Whats New In 2010 (Msdn & Visual Studio)
 
Overview of Lab Management and TFS
Overview of Lab Management and TFSOverview of Lab Management and TFS
Overview of Lab Management and TFS
 
Presentation 1 open source tools in continuous integration environment v1.0
Presentation 1   open source tools in continuous integration environment v1.0Presentation 1   open source tools in continuous integration environment v1.0
Presentation 1 open source tools in continuous integration environment v1.0
 
Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScript
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Presentation
PresentationPresentation
Presentation
 
Codeception
CodeceptionCodeception
Codeception
 
Unit Testing
Unit TestingUnit Testing
Unit Testing
 
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016Acceptance & Functional Testing with Codeception - SunshinePHP 2016
Acceptance & Functional Testing with Codeception - SunshinePHP 2016
 
05 test infrastructure
05   test infrastructure05   test infrastructure
05 test infrastructure
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
 

Kürzlich hochgeladen

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
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
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Kürzlich hochgeladen (20)

Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Automated Testing Of EPiServer CMS Sites

  • 1. Automated testing of EPiServer CMS sitesAn overview of testing in general and specifically EPiServer sites
  • 2. About me Joel Abrahamsson Living in Stockholm Works at Valtech Develops websites with ASP.NET and EPiServer Blogs about web development Founder of the open source projects Page Type Builder, EPiAbstractions and co-founder of EPiMVP
  • 3. Agenda The importance of automation Types of testing xUnit testing Isolating code Challenges when testing EPiServer sites
  • 4. The importance of automation Quick feedback loops Less debugging Limits the human factor Documentation
  • 5. Automation goals We want our tests to be run. Often. By everyone. Tests should be self-checking Tests should be repeatable Tests should be independent of environment Tests should run fast There should be no hassle running our tests.
  • 6. Types of automated tests UI Tests Integration tests Unit tests
  • 7. UI Testing Tests all layers of the application Frameworks Selenium Watin/Watir Can be run using a GUIor as part of xUnit tests Pros Concrete/easy to understand Easy to get started Cons Very slow Hard to maintain Blunt feedback Use for a few key scenarios or when refactoring for testability Write maintainable tests using Page Objects User interface Business logic Data access Database
  • 8. Tests several layers of the application Implemented using Xunit frameworks Pros No isolation required Ensures that whole features work Cons Slow Doesn’t give very accurate feedback Hard to maintain and set up Use to verify functionality of interactions Don’t confuse with unit tests Integration Testing User interface Business logic Data access Database
  • 9. Tests individual units in the system Implemented using Xunit frameworks Pros Fast Precise feedback Can be used to drive developmentand ensure good design Cons Requires isolation/mocking Use to drive development to ensure good design and provide documentation Write tests for design and documentation, not quality assurance Unit Testing User interface Business logic Data access Database
  • 10. The common name for a set of code-driven testing frameworks Test Fixtures Test Suites Assertions Test consists of four phases Set up Exercise Verify Tear down xUnit
  • 11. The verification phase consists of one or several assertions Tests either test state or interactions Verifying state means checking a returned value or ensuring that an object is in a specific state Verifying interactions usually means verifying that the component being tested has performed an interaction with another component. xUnit - Asserts
  • 12. Frameworks NUnit MBUnit xUnit.net Visual Studio Unit Testing Framework / MSTest Executed using test runners on clients and by build servers Many frameworks comes with built in runners Resharper TestDriven.NET xUnit Frameworks
  • 13. Replace a depency with a different component with the same interface to enable and verify interactions Also known as mocking Accomplished using Inversion of Control Replacing interface methods or virtual methods Frameworks Rhino Mocks Moq Isolator NUnit.Mocks Code Isolation
  • 14. Allow a consumer to consume a component without knowing the specifics and origins of the component in advance Implement using Dependency Injection or Service Locator Inversion of Control
  • 15. Inversion of Control – An example
  • 16. Using IoC leads to flexible components Using IoC helps us conform to the SOLID principles The Dependency Inversion Principle - Depend on abstractions, not on concretions The Single Responsibility Principle - A class should have one, and only one, reason to change IoC leads to good design
  • 17. The consumer of the consumer provides the consumer with the component it depends upon Constructor Injection Property Injection Dependency Injection
  • 18. The consumer retrieves the component it depends upon from a third party, a Service Locator Use Dependency Injection instead if you can Service Locator
  • 19. Frameworks for managing dependencies Enable life cycle aware applications A wide range of open source frameworks StructureMap Ninject Unity Castle Windsor Autofac IoC Containers
  • 20. Test Doubles Dummies – objects that are passed around but never used. Fakes – Working implementations Stubs – Provides implementations for certain methods with responses defined in the test Mocks – Same as stubs but with expectations that can be verified Partial mocks Isolation/Mocking terminology
  • 21. Static or non-virtual methods Example: all methods in DataFactory are non-virtual Makes Inversion of Control hard Dependent on it’s configuration Makes it hard to test single units of code Tightly integrated with Web Forms Makes it hard to test without a HTTP Context Complicates Depency Injection EPiServer CMS challenges
  • 22. Create wrappers EPiAbstractions epiabstractions.codeplex.com Beware of security concerns Overcoming static and non-virtual methods
  • 23. Create wrappers Use Page Type Builder to decouple from PageData.Property Partial mocking Overcoming dependencies on the configuration
  • 24. Extract business logic from pages and controls Use Page Type Builder to decouple from PageData.Property pagetypebuilder.codeplex.com The Model View Presenter pattern Web Forms MVP webformsmvp.com EPiMVP github.com/joelabrahamsson/EPiServer-MVP Overcoming tight Web Forms integration
  • 25. Model View Presenter Image from http://geekswithblogs.net/dchristiansen/archive/2007/12/07/microsoft-patterns-and-practices-team-release-the-model-view-presenter.aspx
  • 26. Two base classes for pages and controls, EPiMvpPage and EPiMvpUserControl A base class for presenters, EPiPresenter A presenterfactory that instantiates presenters for views with the view and PageData object Also comes with two presenterfactories that utilizes IoC containers, StructureMap and Ninject EPiMVP - Components
  • 27. A request comes in to the view Web Forms MVP inspects the views PresenterBinding attribute to find the presenter type Web Forms MVP uses a configured (in global.asax) PresenterFactory to instantiate a presenter with a modelobject The presenter, which receives the view and PageData object in the constructor attaches it’s methods to the view’s events EPiMVP – How it works
  • 28. Good candidates for testing include Integrations with external services Utilities (AddQuerystringParameter etc) Custom caching Components that easily get to be complex (example: paging) Bad candidates include Components with extremely little logic Components where the logic is handled by EPiServer (menus etc) Components that deal with, or are closely coupled to, markup Keep in mind that the point of the test isn’t only what it tests but that it drives good design What to (not) test using unit tests
  • 29. Give your tests descriptive names Care about the code in your test Arrange your tests using AAA (Arrange, Act, Assert) Also known as Given-When-Then Be carefull with using code coverage as a measurement Some principles such as the DRY principle isn’t always valid for tests Do not use tools to generate tests. Period. Words of advice