common development and testing tools

23
common development and testing tools Jon Daniel Colin Dean 7 October, 2009

Upload: yen

Post on 05-Jan-2016

25 views

Category:

Documents


3 download

DESCRIPTION

common development and testing tools. Jon Daniel Colin Dean 7 October, 2009. "Programming is managing forgetfulness.". Paul Oehler CTO of InterWorx, LLC. tools every programmer should use. Version Control Code Sniffing Code Testing Unit Testing Functional Testing Acceptance Testing - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: common development and testing tools

common development and testing tools

Jon DanielColin Dean

7 October, 2009

Page 2: common development and testing tools

"Programming is managing forgetfulness."

Paul OehlerCTO of InterWorx, LLC

Page 3: common development and testing tools

tools every programmer should use

• Version Control• Code Sniffing• Code Testing

o Unit Testing o Functional Testingo Acceptance Testingo Regression Testing o Interface (UI) Testing o Continuous Integration

Page 4: common development and testing tools

version control

• Used to store "snapshots" of your codebase• Allow you to create different "branches" of code• Makes merging and identifying changes easy• Helps manage forgetfulness• Can be either centralized or distributed (or a hybrid) • Many different open source packages available

Page 5: common development and testing tools

popular version control systems

• Open Sourceo CVS (Concurrent Versions System)o Subversiono Gito Bazaaro SVKo DARCSo Mercurial (hg)

• Commercialo BitKeepero Perforceo MS Visual SourceSafe

Distributed VCS

Centralized VCS

Page 6: common development and testing tools

centralized versus distributed

• Central management• One repository• Simpler tools• Smaller workflow• Single point of failure

o Ask Jon about rm trunk o Revision history is gold

• Older systems integrated• Branches for version work• Tags for releases

• Many copies of historyo Larger local repoo All history can be local

• Commit then push• Can be centralized

o Bazaar does this (LP)o Git kinda does this

• Every bug fix is a branch• Branches for versions• Branches for releases

http://en.wikipedia.org/wiki/Comparison_of_revision_control_softwarehttp://en.wikipedia.org/wiki/Distributed_revision_control

Page 7: common development and testing tools

PHP_CodeSniffer

• Works with CSS, JavaScript, and PHP files• Is used to detect coding style violations• Can be configured to meet your needs

o Includes templates for coding standards such as Zend and PEAR

• Can be used in conjunction with version control

Page 8: common development and testing tools

JSLint

• Developed by Douglas Crockfordo Author of many JavaScript books you know and love

• Finds common problems in JavaScript code• Yells at you when it thinks you do something stupid

Page 9: common development and testing tools

test-driven development

• Write functionality as tests• One test per method

o Or method set• Write code to pass test

o Try not to modify test• New code = new test

Widget

create()destroy()render()airspeedVelocity()

Widget_Test

test_create()test_destroy()test_render()test_airspeedVelocity()

Page 10: common development and testing tools

Software Testing

It's not the the QA department's job!

Page 11: common development and testing tools

unit testing

• Unit = smallest testable section of code• do_something_small() NOT do_everything() • One test to one class

o Class should generally be a model in MVC paradigmo Not a militant restriction

• Failed test pinpoints problem code • Setup/teardown • Stubs, mockups, fakes• Modular testing

o Tests NEVER rely on another test for anything• Living documentation• Code examples

http://en.wikipedia.org/wiki/Unit_testing

Page 12: common development and testing tools

functional testing

• "Does this action cause a desired state?"• Glue stage between Unit and Acceptance testing

o Tests larger units than Unit testso More opaque than Acceptance tests

• Tests unit interactiono Controller tests in MVCo Controller+View tests in loose MVC

• Tests multiple units simultaneously• Not always run continuously

o May require more resourceso This is but a small hurdle--jump it and move on

Page 13: common development and testing tools

acceptance testing

• Also known as "Black Box" testing• Given certain inputs, certain outputs are received• Does not look at the inner workings of the module• Concerned with high level application testing

o Generally "shallow and wide"o Touching all areas is most important

http://en.wikipedia.org/wiki/Acceptance_testing

Page 14: common development and testing tools

regression testing

• Detects regressiono Reappearances of bugso Decreased performance

• Identifies faults before QA • One regression test per bug

 Excellent example: Automated tests when compiling PHP

""regression testing"? What's that? If it compiles, it is good, if itboots up it is perfect." - LBT

http://en.wikipedia.org/wiki/Regression_testing

Page 15: common development and testing tools

continuous integration

• Practices to decrease development and integration timeso Use source controlo Automate the buildo Builds should automatically test themselves o Commit often and test every buildo Keep the build fasto Test in a clone of production environmento Alert developers of build results

http://en.wikipedia.org/wiki/Continuous_Integration

Page 16: common development and testing tools

automate the build

• Going from source to application should be simple and easy• Less relevant in PHP, but used for tasks such as

o copying code from source to testingo reverting databases to original stateo updating config fileso setting/fixing file permissions o running quick tests to ensure basic functionality

Page 17: common development and testing tools

commit often and test every build

• Never go more than a few days without a commit• Every commit to trunk (or quick set of commits) gets built• Branches should be tested, but this is less important • Never ignore a failing build

Page 18: common development and testing tools

everyone gets builds results

• All developers should be given e-mails of build results• Developers will know quickly if their code has issues • Alert the developer if a commit of theirs has broken the build

o You can alert all developers if you are evil

Page 19: common development and testing tools

continuous integration tools

• Many tools are availableo CruiseControl with PHPUnderControl is common

• Provide automated building as well as other statisticso Build timeso Manage types of builds (full, UI, quick, "on-the-fly")o Percentage of successfully buildso Test coverage

Page 20: common development and testing tools

interface (ui) testing

• In web development, generally a tool that runs tests through a number of web browsers

• Ensures that interactions remain constant and the correct information is displayed

• A useful method of "black box" testing

Page 21: common development and testing tools

selenium remote control

• Useful for testing AJAX operations in your application • Works with Firefox, Safari, Opera, and IE• Includes a Firefox Addon to record macros and generate the

corresponding code• Includes libraries for Java, Perl, PHP, Python, Ruby, .NET• Can use Selenium Grid to "cluster" your tests among many

Operating Systems and browsers

Page 22: common development and testing tools

getting started with unit-testing

• Starting with 0 tests can be scaryo Write simple acceptance testso Write a test for every new featureo Test parts of the code you are sure worko Test parts of code that are used the most o Automate testing from day 1o Strive to have 1% coverage on all classes to start

• Change practices to include test-driven development• Test security related areas• Look into test scaffolding scripts

o Automatically construct and destruct classes

Page 23: common development and testing tools

The End!