SlideShare a Scribd company logo
1 of 9
Web Forms and
automated tests
Michali Konstantinidis
All content by the author unless mentioned otherwise
The problems
●No control over Page, Web and User Control
creation
●Not isolating view from code-behind
○Access web form elements directly in code
●Dependency on ambient statics (Request,
Response, Session, ViewState…)
●Automated tests next to impossible
Some automated tests are still
feasible
●Test end-to-end, from UI to database.
●No quick feedback, expensive to write
●Create/Update/Delete tests: Time-
consuming database setup/teardowns
●Preconditions: Possible a large chain of test
data with relationships
I’m not saying not to have end-to-
end tests
A test harness just needs
to look a bit like this...
Manual tests
UI/Acceptance tests
Integration tests
Unit tests
Model-View-Presenter
●Derivative of the MVC
●The “view” (Web Forms Page) marshalls
user requests, not the presenter
●Usually a 1-to-1 relationship exists between
a view and a presenter
Web Forms with MVP
Key Points
●Presenter contains UI logic, and delegates to
business layer
●View marshalls requests and makes Web
Forms components available to the
Presenter
●The Presenter does not operate on concrete
implementations, only on interfaces!
Test Isolation
●Framework components accessible by
statics can be wrapped or accessed via
abstract classes, if available, and mocked
○Session - HttpSessionStateBase
○HttpContext - HttpContextWrapper
○Or make those available via a Page subclass
●Leave View with barely existing logic,
making it not worth testing
And, that’s (almost) it
●Circular reference between View and
Presenter. “Newing-up” of objects should be
done in one place, in a factory.
●Dependency Injection in Web Forms?
○Unity.WebForms - by S. Kyle Korndoerfer

More Related Content

What's hot

What's hot (6)

Amruth-Testing
Amruth-TestingAmruth-Testing
Amruth-Testing
 
Depurando VBScript no InduSoft Web Studio
Depurando VBScript no InduSoft Web StudioDepurando VBScript no InduSoft Web Studio
Depurando VBScript no InduSoft Web Studio
 
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing ToolsHDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
HDC 2010 - Creating Quality Software: A Look at Visual Studio 2010 Testing Tools
 
Testing of Microservices in a Cloud Environment
Testing of Microservices in a Cloud EnvironmentTesting of Microservices in a Cloud Environment
Testing of Microservices in a Cloud Environment
 
Grading the Quality of Selenium Tests
Grading the Quality of Selenium TestsGrading the Quality of Selenium Tests
Grading the Quality of Selenium Tests
 
Design Patterns for Smart Applications
Design Patterns for Smart ApplicationsDesign Patterns for Smart Applications
Design Patterns for Smart Applications
 

Viewers also liked

las tics y la enseñanza - consumos culturales
las tics y la enseñanza - consumos culturales las tics y la enseñanza - consumos culturales
las tics y la enseñanza - consumos culturales
yaniriquelme
 
Testimonial Sören Venderby Origio May 2015
Testimonial Sören Venderby Origio May 2015Testimonial Sören Venderby Origio May 2015
Testimonial Sören Venderby Origio May 2015
PhD Lars Johansson
 
Eng9 american literature
Eng9 american literatureEng9 american literature
Eng9 american literature
Tine Lachica
 

Viewers also liked (16)

8 DE MARZO EN EL PARLAMENTO EUROPEO MUJERES REFUGIADAS
8 DE MARZO EN EL PARLAMENTO EUROPEO MUJERES REFUGIADAS8 DE MARZO EN EL PARLAMENTO EUROPEO MUJERES REFUGIADAS
8 DE MARZO EN EL PARLAMENTO EUROPEO MUJERES REFUGIADAS
 
las tics y la enseñanza - consumos culturales
las tics y la enseñanza - consumos culturales las tics y la enseñanza - consumos culturales
las tics y la enseñanza - consumos culturales
 
Nada+Essam+El-din+Mohamed
Nada+Essam+El-din+MohamedNada+Essam+El-din+Mohamed
Nada+Essam+El-din+Mohamed
 
DN - Coimbra com desempenho acima da média no turismo - Miguel Guedes de Sousa
DN - Coimbra com desempenho acima da média no turismo - Miguel Guedes de SousaDN - Coimbra com desempenho acima da média no turismo - Miguel Guedes de Sousa
DN - Coimbra com desempenho acima da média no turismo - Miguel Guedes de Sousa
 
Slide 1
Slide 1Slide 1
Slide 1
 
Gerencia industrial
Gerencia industrialGerencia industrial
Gerencia industrial
 
Testimonial Sören Venderby Origio May 2015
Testimonial Sören Venderby Origio May 2015Testimonial Sören Venderby Origio May 2015
Testimonial Sören Venderby Origio May 2015
 
MJE Core Expertise
MJE Core ExpertiseMJE Core Expertise
MJE Core Expertise
 
rz_9_15
rz_9_15rz_9_15
rz_9_15
 
Apresentação SR Consultoria
Apresentação SR ConsultoriaApresentação SR Consultoria
Apresentação SR Consultoria
 
Document unic pentru achizițiile publice europene (DUAE)
Document unic pentru achizițiile publice europene (DUAE)Document unic pentru achizițiile publice europene (DUAE)
Document unic pentru achizițiile publice europene (DUAE)
 
Mardi 18 mme Géraldine Leduc - présentation ANETT
Mardi 18   mme Géraldine Leduc - présentation ANETTMardi 18   mme Géraldine Leduc - présentation ANETT
Mardi 18 mme Géraldine Leduc - présentation ANETT
 
Эффективность власти в решении проблем жителей Донбасса и временно перемещенн...
Эффективность власти в решении проблем жителей Донбасса и временно перемещенн...Эффективность власти в решении проблем жителей Донбасса и временно перемещенн...
Эффективность власти в решении проблем жителей Донбасса и временно перемещенн...
 
AWS re:Invent 2016: Zillow Group: Developing Classification and Recommendatio...
AWS re:Invent 2016: Zillow Group: Developing Classification and Recommendatio...AWS re:Invent 2016: Zillow Group: Developing Classification and Recommendatio...
AWS re:Invent 2016: Zillow Group: Developing Classification and Recommendatio...
 
Diseccion de riñones
Diseccion de riñonesDiseccion de riñones
Diseccion de riñones
 
Eng9 american literature
Eng9 american literatureEng9 american literature
Eng9 american literature
 

Similar to Web forms and automated tests

Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
MaslowB
 

Similar to Web forms and automated tests (20)

Android Architectures
Android ArchitecturesAndroid Architectures
Android Architectures
 
4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I4. Introduction to ASP.NET MVC - Part I
4. Introduction to ASP.NET MVC - Part I
 
Clean architecture on android
Clean architecture on androidClean architecture on android
Clean architecture on android
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Introduction to asp.net mvc
Introduction to asp.net mvcIntroduction to asp.net mvc
Introduction to asp.net mvc
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
Effective performance evaluation as part of a CI approach - Mission Impossible?
Effective performance evaluation as part of a CI approach - Mission Impossible?Effective performance evaluation as part of a CI approach - Mission Impossible?
Effective performance evaluation as part of a CI approach - Mission Impossible?
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
 
AngularJS Basics - Knowledge Sharing
AngularJS Basics - Knowledge SharingAngularJS Basics - Knowledge Sharing
AngularJS Basics - Knowledge Sharing
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Single Page Application presentation
Single Page Application presentationSingle Page Application presentation
Single Page Application presentation
 
Introduction To MVVM
Introduction To MVVMIntroduction To MVVM
Introduction To MVVM
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
 
Understanding ASP.NET MVC
Understanding ASP.NET MVCUnderstanding ASP.NET MVC
Understanding ASP.NET MVC
 
Effort estimation for web applications
Effort estimation for web applicationsEffort estimation for web applications
Effort estimation for web applications
 
QAorHighway2016
QAorHighway2016QAorHighway2016
QAorHighway2016
 
Introduction to-angular js
Introduction to-angular jsIntroduction to-angular js
Introduction to-angular js
 
MVC architecture
MVC architectureMVC architecture
MVC architecture
 
Automated Testing of Web Applications
Automated Testing of Web ApplicationsAutomated Testing of Web Applications
Automated Testing of Web Applications
 

Recently uploaded

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 

Recently uploaded (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 

Web forms and automated tests

  • 1. Web Forms and automated tests Michali Konstantinidis All content by the author unless mentioned otherwise
  • 2. The problems ●No control over Page, Web and User Control creation ●Not isolating view from code-behind ○Access web form elements directly in code ●Dependency on ambient statics (Request, Response, Session, ViewState…) ●Automated tests next to impossible
  • 3. Some automated tests are still feasible ●Test end-to-end, from UI to database. ●No quick feedback, expensive to write ●Create/Update/Delete tests: Time- consuming database setup/teardowns ●Preconditions: Possible a large chain of test data with relationships
  • 4. I’m not saying not to have end-to- end tests A test harness just needs to look a bit like this... Manual tests UI/Acceptance tests Integration tests Unit tests
  • 5. Model-View-Presenter ●Derivative of the MVC ●The “view” (Web Forms Page) marshalls user requests, not the presenter ●Usually a 1-to-1 relationship exists between a view and a presenter
  • 7. Key Points ●Presenter contains UI logic, and delegates to business layer ●View marshalls requests and makes Web Forms components available to the Presenter ●The Presenter does not operate on concrete implementations, only on interfaces!
  • 8. Test Isolation ●Framework components accessible by statics can be wrapped or accessed via abstract classes, if available, and mocked ○Session - HttpSessionStateBase ○HttpContext - HttpContextWrapper ○Or make those available via a Page subclass ●Leave View with barely existing logic, making it not worth testing
  • 9. And, that’s (almost) it ●Circular reference between View and Presenter. “Newing-up” of objects should be done in one place, in a factory. ●Dependency Injection in Web Forms? ○Unity.WebForms - by S. Kyle Korndoerfer