(Web) Testing for Pythonistas C. Titus Brown Grig Gheorghiu C. Titus Brown Grig Gheorghiu.

Slides:



Advertisements
Similar presentations
Implementing Tableau Server in an Enterprise Environment
Advertisements

(Thinking About) Introducing Agile Testing to the One Laptop Per Child Project C. Titus Brown Asst. Prof., Michigan State U. C. Titus Brown.
Test Automation: Coded UI Test
An open source QA stack testing tools for agile teams Presented by Aaron Evans
Software Testing with Visual Studio 2013 & Team Foundation Server 2013 Benjamin Day.
Trnsport Test Suite Project Tony Compton, Texas DOT Charles Engelke, Info Tech.
Creating a Program In today’s lesson we will look at: what programming is different types of programs how we create a program installing an IDE to get.
How to Optimize Your Existing Regression Testing Arthur Hicken May 2012.
Languages for Dynamic Web Documents
E-commerce Project Erik Zeitler Erik Zeitler2 Lab 2  Will be anounced and scheduled later  We will deploy Java Server Pages on a Tomcat server.
PHP (2) – Functions, Arrays, Databases, and sessions.
Introduction to Eclipse, Unit Testing and JUnit David Rabinowitz.
HTML Form Processing Learning Web Design – Chapter 9, pp Squirrel Book – Chapter 11, pp
Debugging CPSC 315 – Programming Studio Fall 2008.
1 Software Testing and Quality Assurance Lecture 30 – Testing Systems.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Exporting reports – Data Integration & Presentation What is involved in presenting report data in other ways? What is involved in presenting report data.
Agile Testing with Testing Anywhere The road to automation need not be long.
© 2006, Cognizant Technology Solutions. All Rights Reserved. The information contained herein is subject to change without notice. Automation – How to.
Professional Informatics & Quality Assurance Software Lifecycle Manager „Tools that are more a help than a hindrance”
Introduction to Continuous Integration Mike Roberts.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Estimation Wrap-up CSE 403, Spring 2008, Alverson Spolsky.
Project Proposal: Academic Job Market and Application Tracker Website Project designed by: Cengiz Gunay Client: Cengiz Gunay Audience: PhD candidates and.
Lecturer: Ghadah Aldehim
INTRODUCTION TO WEB DATABASE PROGRAMMING
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Samuvel Johnson nd MCA B. Contents  Introduction to Real-time systems  Two main types of system  Testing real-time software  Difficulties.
1 The Problem Do you have: A legacy ABL system with millions of Lines of ABL Code? Years and years of modifications to your ABL code? System documentation.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Craig Berntson
GDT V5 Web Services. GDT V5 Web Services Doug Evans and Detlef Lexut GDT 2008 International User Conference August 10 – 13  Lake Las Vegas, Nevada GDT.
London April 2005 London April 2005 Creating Eyeblaster Ads The Rich Media Platform The Rich Media Platform Eyeblaster.
Integrating with UCSF’s Shibboleth system
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
1 Tradedoubler & Mobile Mobile web & app tracking technical overview.
©2010 John Wiley and Sons Chapter 12 Research Methods in Human-Computer Interaction Chapter 12- Automated Data Collection.
COMP3121 E-Commerce Technologies Richard Henson University of Worcester November 2011.
Testing Tools for Programmers (twill, scotch, figleaf, wsgi_intercept, and pinocchio) C. Titus Brown C. Titus Brown Talk.
Sustainability: Web Site Statistics Marieke Napier UKOLN University of Bath Bath, BA2 7AY UKOLN is supported by: URL
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Click your to move to each slide Utilizing Ozquest software Tracking via the webTracking via the web.
CGI Common Gateway Interface. CGI is the scheme to interface other programs to the Web Server.
Sofia Bulgaria Summer School IST eXPERT: Best Practice on e-Project Development 30 June - 2 July 2003 eXtreme programming.
First Indico Workshop WEB FRAMEWORKS Adrian Mönnich May 2013 CERN.
INFO1408 Database Design Concepts Week 15: Introduction to Database Management Systems.
TEST-1 6. Testing & Refactoring. TEST-2 How we create classes? We think about what a class must do We focus on its implementation We write fields We write.
SBTeach Introduction School of Business Course Coordination System.
Chapter 7 The Practices: dX. 2 Outline Iterative Development Iterative Development Planning Planning Organizing the Iterations into Management Phases.
© 2010 Deep Web Technologies, Inc. Taking the Library Back from Google Abe Lederman, President and CTO Deep Web Technologies May 12, 2010.
Introduction Selenium IDE is a Firefox extension that allows you to record, edit, and debug tests for HTML Easy record and playback Intelligent field selection.
Database Projects in Visual Studio Improving Reliability & Productivity.
COMP3241 E-Commerce Technologies Richard Henson University of Worcester November 2014.
Automated Testing in Sakai Testing applications and services in isolation and in context Josh Holtzman, UC Berkeley David Haines, University of Michigan.
T EST T OOLS U NIT VI This unit contains the overview of the test tools. Also prerequisites for applying these tools, tools selection and implementation.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Continuous Delivery and Team Foundation Server 2013 Ognjen Bajić Ana Roje Ivančić Ekobit.
Modern web tools and midas Ben Smith TRIUMF Midas workshop – July 2015 Ben Smith - Modern web tools and Midas 1 15/07/15.
Software Engineering Lecture 11 Software Testing Presenter: Josef Hallberg 1.
Ognjen Bajić Ana Roje Ivančić Ekobit Efficient Application Testing.
Real Testing Scenario Strategy: A Real-life TestOps Environment
A Simple Introduction to Git: a distributed version-control system
Dynamic Web Pages JavaScript Jill Thomas Oct 14, 2003.
Real Testing Scenario Strategy: Bringing this all together – Success!
CSCE 315 – Programming Studio, Fall 2017 Tanzir Ahmed
Unit 6: Application Development
CSE 303 Concepts and Tools for Software Development
Your code is not just…your code
Jamie Cool Program Manager Microsoft
Your code is not just…your code
Presentation transcript:

(Web) Testing for Pythonistas C. Titus Brown Grig Gheorghiu C. Titus Brown Grig Gheorghiu

This tutorial is for you Ask questions. Ask about specifics. Demand demos. (Grig and I are secure in our abilities) Ask questions. Ask about specifics. Demand demos. (Grig and I are secure in our abilities)

Rough outline Why test? Testing strategies. Low-level testing tool overview. UI and acceptance tests. Continuous integration. Open Q&A. Why test? Testing strategies. Low-level testing tool overview. UI and acceptance tests. Continuous integration. Open Q&A.

Online resources Code etc. will be posted after tutorial. ‘testing-in-python’ mailing list. Us, in person & via . O’Reilly E-book, “Functional Web Testing” Code etc. will be posted after tutorial. ‘testing-in-python’ mailing list. Us, in person & via . O’Reilly E-book, “Functional Web Testing”

Why write automated tests? 1) Because you want your code to work.

Why write automated tests? 1) Because you want your code to work. 2) Because you want your code to meet customer expectations. 1) Because you want your code to work. 2) Because you want your code to meet customer expectations.

Why write automated tests? 1) Because you want your code to work. 2) Because you want your code to meet customer expectations. 3) Because you want to simplify your (programming) life. 1) Because you want your code to work. 2) Because you want your code to meet customer expectations. 3) Because you want to simplify your (programming) life.

Why write automated tests? 1) Because you want your code to work. 2) Because you want your code to meet customer expectations. 3) Because you want to simplify your (programming) life. 4) Because you often over- or under-design your code. 1) Because you want your code to work. 2) Because you want your code to meet customer expectations. 3) Because you want to simplify your (programming) life. 4) Because you often over- or under-design your code.

Goal: become “test infected” Integrate “the testing way” into your daily life. It is now actually psychologically uncomfortable for me to write code that is difficult to test. (This speaks to tools as well.) Integrate “the testing way” into your daily life. It is now actually psychologically uncomfortable for me to write code that is difficult to test. (This speaks to tools as well.)

Some test guidelines Keep your testing infrastructure as simple and stupid as possible. Testing should help you write & debug your other code, not become a major part of the codebase in and of itself… Always be ready to throw out your test code! Keep your testing infrastructure as simple and stupid as possible. Testing should help you write & debug your other code, not become a major part of the codebase in and of itself… Always be ready to throw out your test code!

Some test guidelines Start small. Build tests incrementally. Smoke tests are absurdly useful. Test simply, at many levels. Focus on actual problem areas (existing bugs). Continuously integrate. Start small. Build tests incrementally. Smoke tests are absurdly useful. Test simply, at many levels. Focus on actual problem areas (existing bugs). Continuously integrate.

Using testing as part of your process Use tests personally, even if other people don’t. Manage up and across. Automate what can be easily automated, nothing more. (Corollary: plan for testability) Start small and KISS. Use tests personally, even if other people don’t. Manage up and across. Automate what can be easily automated, nothing more. (Corollary: plan for testability) Start small and KISS.

Testing Taxonomy (only somewhat useful) Unit tests Functional tests Regression tests User interface tests Acceptance tests Integration tests Continuous integration Performance tests Unit tests Functional tests Regression tests User interface tests Acceptance tests Integration tests Continuous integration Performance tests

Testing Strategies

“TDD” vs “SDT” or “TED” Test Driven Development: write tests first

“TDD” vs “SDT” or “TED” Test Driven Development: write tests first Stupidity Driven Testing: write tests after you do something stupid, to make sure you never make the same mistake again. (a.k.a. “Test Enhanced Development” ;) Test Driven Development: write tests first Stupidity Driven Testing: write tests after you do something stupid, to make sure you never make the same mistake again. (a.k.a. “Test Enhanced Development” ;)

Constrain your code Document your expectations, internally and externally. Use assert more. (internal) Write unit, functional, and regression tests in terms of expectations. (external) “This function better do X, or else…” Document your expectations, internally and externally. Use assert more. (internal) Write unit, functional, and regression tests in terms of expectations. (external) “This function better do X, or else…”

“Tracer bullet” development Write an end-to-end test (e.g. Web browser -> database & back) 1) If it doesn’t work, go no further! 2) Exercises your setup and teardown code. 3) Gives you a base from which to expand. Write an end-to-end test (e.g. Web browser -> database & back) 1) If it doesn’t work, go no further! 2) Exercises your setup and teardown code. 3) Gives you a base from which to expand.

Build a “test umbrella” One command -> all tests. 1) Integrated reporting 2) Ease of use and “startup” 3) No memory required (nose, py.test) One command -> all tests. 1) Integrated reporting 2) Ease of use and “startup” 3) No memory required (nose, py.test)

Using regression tests Before you can ask why did that change? …you must be able to know Did something change? Before you can ask why did that change? …you must be able to know Did something change?

Refactoring Incrementally change code while keeping the codebase working. Refactoring becomes stress free with reasonably thorough testing. Incrementally change code while keeping the codebase working. Refactoring becomes stress free with reasonably thorough testing.

Code coverage Use code coverage (line coverage) to target new tests. People will tell you that code coverage is not a good metric. They’re right, in theory. But if you’re not running every line of code in your application at least once during your tests, you can’t know if that line works. (Duh.) Use code coverage (line coverage) to target new tests. People will tell you that code coverage is not a good metric. They’re right, in theory. But if you’re not running every line of code in your application at least once during your tests, you can’t know if that line works. (Duh.)

Continuous integration Set your tests up to run automatically with a single click, in several environments. Yes, this helps you figure out if your code still works. But it also helps you in many less obvious ways: 1) Did you introduce an environment dependency? 2) Did you add a new package/library requirement? 3) Environment & package requirements become explicit 4) Indisputable and impersonal evidence that something is broken! Set your tests up to run automatically with a single click, in several environments. Yes, this helps you figure out if your code still works. But it also helps you in many less obvious ways: 1) Did you introduce an environment dependency? 2) Did you add a new package/library requirement? 3) Environment & package requirements become explicit 4) Indisputable and impersonal evidence that something is broken!

Integrating testing into your customer interaction process Rationale: the point of programming is (usually) to deliver something that a customer actually wants. (…not what they think they want…) This is a communication problem. Rationale: the point of programming is (usually) to deliver something that a customer actually wants. (…not what they think they want…) This is a communication problem.

Summary Testing should be an integral part of your process. If it’s not working for you, don’t force it but don’t give up, either! Address real problems. Simplify. There is no try, only do. Testing should be an integral part of your process. If it’s not working for you, don’t force it but don’t give up, either! Address real problems. Simplify. There is no try, only do.

“Low-level” testing tools nose -- unit test discovery & execution twill -- functional Web testing (+ extensions) wsgi_intercept -- talk directly to WSGI apps (hard to explain…) scotch -- record & replay Web traffic figleaf -- code coverage analysis nose -- unit test discovery & execution twill -- functional Web testing (+ extensions) wsgi_intercept -- talk directly to WSGI apps (hard to explain…) scotch -- record & replay Web traffic figleaf -- code coverage analysis

Testing tools for programmers must be simple, easy to deploy & use, and configurable. Otherwise people won’t use them.

Functional Web testing with twill go formvalue 1 q “google query statistics” submit show forms, cookies, redirects, http basic auth, link following, link checking, http code assertions, test for text presence/nonpresence, tidy checking, etc. no JavaScript support ;( go formvalue 1 q “google query statistics” submit show forms, cookies, redirects, http basic auth, link following, link checking, http code assertions, test for text presence/nonpresence, tidy checking, etc. no JavaScript support ;(

twill is Python from twill.commands import * go(‘ showforms() formvalue(‘1’, ‘q’, “google query statistics”) submit() show() All base twill commands directly accessible from Python. Additionally, a “nice” wrapper around mechanize is available. from twill.commands import * go(‘ showforms() formvalue(‘1’, ‘q’, “google query statistics”) submit() show() All base twill commands directly accessible from Python. Additionally, a “nice” wrapper around mechanize is available.

wsgi_intercept lets twill talk directly to WSGI apps. app = get_wsgi_app() import twill twill.add_wsgi_intercept(‘localhost’, 80, lambda: app) twill.commands.go(‘ … twill.remove_wsgi_intercept(‘ This is fairly close in concept to paste.fixture, but you can use the same script for testing a direct WSGI connection as you can for testing your whole “Web stack” (server + middleware + app). (Will show you demo) app = get_wsgi_app() import twill twill.add_wsgi_intercept(‘localhost’, 80, lambda: app) twill.commands.go(‘ … twill.remove_wsgi_intercept(‘ This is fairly close in concept to paste.fixture, but you can use the same script for testing a direct WSGI connection as you can for testing your whole “Web stack” (server + middleware + app). (Will show you demo)

scotch lets you record & replay WSGI data, and generate twill scripts too. app = get_wsgi_app() import scotch.recorder recorder = scotch.recorder.Recorder(app) serve_wsgi(recorder) … app = get_wsgi_app() for record in recorder.record_holder: print record.replay(app) app = get_wsgi_app() import scotch.recorder recorder = scotch.recorder.Recorder(app) serve_wsgi(recorder) … app = get_wsgi_app() for record in recorder.record_holder: print record.replay(app)

figleaf is a code coverage recording tool. import figleaf figleaf.start() … figleaf.stop() figleaf.write_coverage(‘.figleaf’) Intended for programmatic use; can take coverage from multiple runs/deployments/platforms, and intersect/union results. Can retrieve from running Web server. (Works fine as a replacement for coverage.py, too) import figleaf figleaf.start() … figleaf.stop() figleaf.write_coverage(‘.figleaf’) Intended for programmatic use; can take coverage from multiple runs/deployments/platforms, and intersect/union results. Can retrieve from running Web server. (Works fine as a replacement for coverage.py, too)