Pex

678 views

Published on

DDD7

http://blog.benhall.me.uk/2008/11/ddd7-slides-and-code-pex-future-of-unit.html

Published in: Technology, Sports
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
678
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • http://www.flickr.com/search/?q=weather+sunny&l=4&page=2http://www.flickr.com/photos/djbrady/1460272108/
  • http://www.flickr.com/search/?q=storm+lightning&s=int&l=4http://www.flickr.com/photos/yukonblizzard/2562986305/
  • http://www.flickr.com/search/?q=fog+forest&l=4&page=2http://www.flickr.com/photos/frielp/6829509/
  • http://www.flickr.com/photos/atomicjeep/274667176/
  • http://www.flickr.com/search/?l=4&w=all&q=weather+cloudy&m=texthttp://www.flickr.com/photos/wouterpostma/695850212/
  • http://www.flickr.com/photos/leon_homan/2856628778/
  • http://xkcd.com/303/
  • Adapted from http://xkcd.com/303/
  • Pex

    1. 1. PexThe future of unit testing? Ben Hall Ben@BenHall.me.uk Blog.BenHall.me.uk
    2. 2. Agenda• What is Pex?• Problem Pex is trying to solve• Pex in the Real World• The future?
    3. 3. What is Pex?
    4. 4. Program Exploration
    5. 5. Microsoft ResearchResearch in Software Engineering (RiSE)
    6. 6. Nikolai TillmannPeli de HalleuxWolfram SchulteNikolaj Bjørner
    7. 7. Nikolai TillmannPeli de HalleuxWolfram SchulteNikolaj Bjørner
    8. 8. Pex generates inputs for your unittests through automate exploratory testing
    9. 9. Identify Test Inputs• Pex doesn’t make wild guesses• Pex gains an understanding of your code• Static and dynamic analysis• Every input should increase code coverage
    10. 10. Parameterised Unit Tests[RowTest][Row(1, 2, 3)][Row(-1, -2, -3)]public void TestForAddMethod(int a, int b, intexpected){ int test = MyMethods.Add(a, b); Assert.AreEqual(test, expected);}
    11. 11. Parameterised Unit Tests[RowTest][Row(1, 2, 3)][Row(-1, -2, -3)]public void TestForAddMethod(int a, int b, intexpected){ int test = MyMethods.Add(a, b); Assert.AreEqual(test, expected);}
    12. 12. Everything Ian said is still valid
    13. 13. Exploratory Testing• Learns more over time• More it knows, more it knows how to break it• Starts with simplest input
    14. 14. DEMOHELLO WORLD
    15. 15. Under the covers
    16. 16. CLR Profiler APIICorProfilerCallback2
    17. 17. Z3 Constraint Solver
    18. 18. The Problem
    19. 19. Some people aren’t unit testing Ok... Most people
    20. 20. Lots of people think they arewriting tests but in reality they aren’t
    21. 21. [Test]public void Test1(){ Engine e = new Engine(); Customer c = e.GetCustomer(123); Order o = new Order(1, “Product X”) o.Customer = c; Assert.IsTrue(e.PlaceOrder(o));}
    22. 22. Those who are, 100% code coverage is rare Especially with Legacy Code
    23. 23. Test Driven Development on complex code is difficult
    24. 24. Encryption and Decryption algorithms
    25. 25. Parsers and Compilers
    26. 26. Decision Tables
    27. 27. Aim of Pex is to solve these problems
    28. 28. The Real World
    29. 29. DEMODECISION TABLE
    30. 30. DEMOIP ADDRESS GENERATOR
    31. 31. DEMOPEX EXTENSIONS
    32. 32. The Future
    33. 33. Pex has limitationsRemember – it’s still research
    34. 34. Difficult to start usingRemember – it’s still research
    35. 35. Not available under a commercial license VS2008 == ResearchVS2010 == Same as VS2010 CTP
    36. 36. However!
    37. 37. Very good with algorithms and complex code
    38. 38. Used internally to test core component at Microsoft
    39. 39. Code Contracts help guide Pex Spec# C# 4.0
    40. 40. BDD and Pex
    41. 41. In summary...
    42. 42. Summary• Pex is a project from Microsoft research• Available today for VS2008 and VS2010• Aims to make unit testing more effective• BDD + Pex
    43. 43. Thank you Ben HallBen@BenHall.me.ukBlog.BenHall.me.uk
    44. 44. Resources• http://Blog.BenHall.me.uk• http://research.microsoft.com/pex/• http://www.codeplex.com/pex• http://blog.dotnetwiki.org/ (Peli’s Blog)• http://blogs.msdn.com/nikolait• PDC Session - http://channel9.msdn.com/pdc2008/TL51
    45. 45. Flickr Images• http://www.flickr.com/photos/djbrady/1460272108/• http://www.flickr.com/photos/yukonblizzard/2562986 305/• http://www.flickr.com/photos/frielp/6829509/• http://www.flickr.com/photos/atomicjeep/274667176/• http://www.flickr.com/photos/wouterpostma/6958502 12/• http://www.flickr.com/photos/leon_homan/28566287 78/• http://www.flickr.com/photos/sadsnaps/2741479621/

    ×