Published on

Talk for undergraduates on why they should embrace testing

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Testing

    1. 1. Testing Steve Loughran HP Laboratories June 9th, 2008
    2. 2. About me <ul><li>I break things for a living </li></ul><ul><li>this is because I am clumsy </li></ul><ul><li>breaking other people’s code is fun </li></ul><ul><li>sometimes it is really hard </li></ul>
    3. 3. Ant in Action <ul><li>the problems of complex builds in big teams </li></ul><ul><li>not for this course </li></ul><ul><li>stay in the IDE </li></ul><ul><li>testing is key to getting big projects out the door </li></ul><ul><li>automation comes next </li></ul>
    4. 4. your code doesn't work
    5. 5. I know this because...
    6. 6. my code doesn't work
    7. 7. it's OK to write code that doesn’t work
    8. 8. but not to ship it
    9. 9. especially when it matters
    10. 10. how do you get from &quot;broken&quot; to &quot;shipping&quot;?
    11. 11. Device Drivers ship and see test it! Test-Driven  x:  y : f ( y , x) > 0 Formal Methods prove it works
    12. 12. proofs of correctness <ul><li>shows an algorithm really works </li></ul><ul><li>good for concurrency </li></ul><ul><li>and other things you can’t test </li></ul><ul><li>makes assumptions about system </li></ul><ul><li>needs lots of maths/CS skills (Pi-Calculus, The HOL System) </li></ul><ul><li>how do you do regression proofs? </li></ul>
    13. 13. Testing: code that breaks <ul><li>unit test: test classes, libraries </li></ul><ul><li>functional test: test the application </li></ul><ul><li>system test: test a deployed system </li></ul><ul><li>performance test: simulate load. </li></ul><ul><li>acceptance tests: is it ready for use? </li></ul><ul><li>a good test breaks the build! </li></ul>
    14. 14. Test Driven Development any feature without a test doesn’t exist
    15. 15. Lots of unit test frameworks <ul><li>Java: JUnit, TestNG </li></ul><ul><li>Python: PyUnit </li></ul><ul><li>Ruby: Test:: Unit </li></ul><ul><li>.NET: NUnit </li></ul><ul><li>PHP: PHPUnit </li></ul><ul><li>C++ (CppUnit) </li></ul>
    16. 16. JUnit <ul><li>main unit test framework in Java (see also TestNG) </li></ul><ul><li>simple to learn </li></ul><ul><li>good tool support </li></ul><ul><li>somewhat low-level </li></ul><ul><li>extensions for system testing </li></ul>
    17. 18. public class LessSimpleTest extends TestCase { public LessSimpleTest (String s) { super(s); } public void testAssignment() { final Date date = new Date(); Event event = new Event(UUID.randomUUID(), date, &quot;now&quot;, &quot;Text&quot;); assertEquals(&quot;self equality failed&quot;, event, event); assertEquals(date, event.getDate()); assertNotNull(date.getID()); } }
    18. 19. swing GUI TestRunner
    19. 20. Ant-generated report scales better; reports published
    20. 21. Continuous Integration see: CruiseControl, Hudson, LuntBuild
    21. 22. ==> blame assignment whose change broke the build?
    22. 23. System Testing <ul><li>deploy, then: HtmlUnit, XmlUnit, Cactus, Selenium </li></ul><ul><li>needs automated deployment, database setup, teardown </li></ul><ul><li>performance testing by comparing timings w.r.t. old runs </li></ul><ul><li>simulate entire behaviour of the client user/application </li></ul>
    23. 24. Distributed Systems <ul><li>testing is still a research topic </li></ul><ul><li>set up complex configurations </li></ul><ul><li>run tests on remote machines </li></ul><ul><li>collect results and log data </li></ul><ul><li>post-mortem analysis </li></ul><ul><li>virtualization can help </li></ul><ul><li>see http://tinyurl.com/y99tez </li></ul>
    24. 25. limitations of testing <ul><li>good tests are hard to write </li></ul><ul><li>distributed tests very hard </li></ul><ul><li>different system configurations are still a problem </li></ul><ul><li>status of &quot;tester&quot; below &quot;coder&quot; </li></ul><ul><li>A good test breaks the application </li></ul>
    25. 26. politics: resistance to change
    26. 27. developers: ignorance, fear <ul><li>E.E.E. Educate, Evangelise, Encourage </li></ul><ul><li>gently show benefits </li></ul><ul><li>use testing to track down a bug </li></ul><ul><li>retain test for regression testing </li></ul><ul><li>add tests for new code and old problems, not existing codebase </li></ul><ul><li>adopt cruise control, reporting </li></ul>
    27. 28. management: ignorance <ul><li>&quot;too much time spent on testing&quot; </li></ul><ul><li>out of date with modern processes </li></ul><ul><li>belief that testing slows the schedule (it does on the ship-and-see process) </li></ul><ul><li>E.E.E., then D.D.D: Distract, Dissemble, Defeat </li></ul>
    28. 29. call to action <ul><li>write tests </li></ul><ul><li>use a CI tool: Hudson, Luntbuild, Cruise Control </li></ul>