Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Let's make this test suite run faster!
Let's make this test suite run faster!
               Why?




             What for ?




                               ...
You test early and often
      Don’t you?




                           http://farm1.static.flickr.com/97/246816211_573c29...
Continuous integration, continuous testing...
      ...even continuous deployment




                                    ...
Testing often
Often means waiting a lot




                            http://farm3.static.flickr.com/2505/3772118924_11fe...
Your coding room doesn’t have to look like this




                  What for ?




                                     ...
Tests can be fast
Even if lines of code keep growing
Easy!
Let’s distribute across multiple hudson servers
It doesn’t have to be complicated
    I’ll share a few simple tricks
It can make your product better
Simple to test, means simple to write, deploy and USE




                                ...
How can we accelerate the tests?



     The Cheater
     The Lazy
     The Brave




                                   h...
The Cheater
The Lazy
The Brave




              http://all-the-movies.cowblog.fr/images/arton1122.jpg
Buy a faster machine
Tests are cpu/memory bound




                         http://farm1.static.flickr.com/28/93569705_1c5...
Be warned
Single threaded tests get slower over time


    100

     75

     50

     25

      0
          2007   2008  ...
Use all the cores
parallel build with maven3




mvn -T1 clean install : 5:05s
mvn -T4 clean install : 3:10s
Use all the cores
parallel build with maven3
Use all the cores
For JUnit/TestNG tests




                         .
The Cheater
The Lazy
The Brave




              http://all-the-movies.cowblog.fr/images/arton1122.jpg
Delete redundant tests
It’s so simple, we don’t do it...




                               http://geekandpoke.typepad.com...
Even better, delete dead code
To delete yet other useless tests




                                http://farm1.static.fli...
Work in a sandbox
       The network is too slow


     In-memory database: H2




Behaves more like MySql than Hsqldb
It’s Not only SQL




If going with NoSQL, take a server that
          can run in-process

            eg. Voldemort
In-memory SMTP Server
      Ethereal
Everything local and in-memory
              Files




Apache VFS (Virtual File System)
      Spring Resource...




     ...
The Cheater
The Lazy
The Brave




              http://all-the-movies.cowblog.fr/images/arton1122.jpg
Don’t test business rules in integration tests
      Unit tests is often a better place




                              ...
Don’t test business rules in integration tests
      Unit tests is often a better place
                     Functional te...
Take the longer integration test
Break it in one faster integration test
    and a lot of small unit tests




           ...
Or mock the slowest layers
eg. functional test with Spring and Mockito
Or mock the slowest layers
eg. functional test with Spring and Mockito




                                       Mocks ar...
Don’t test through the browser
  Selenium is often overkill

                 «But my application is
                     ...
Really ?




           http://i.zdnet.com/blogs/complexity-and-false-hope.jpg
Complexity has a cost
That you pay each time a test runs




                             http://thehongkongfixereng.files.w...
Test through the browser the strict minimal
     Use javascript unit tests for the rest




                              ...
I tend to be old school
And write server-side code most of the time




                                     http://www.ce...
One more thing...




Simplify and optimize your code

      Tests will run faster




                                  .
Thank you
   Q/A
Who am I?



        David Gageot

      CTO algodeal.com
      The Crowd Sourced
      Quant Hedge Fund

              @d...
Prochain SlideShare
Chargement dans…5
×

Let's make this test suite run faster! SoftShake 2010

2 132 vues

Publié le

The more the tests, the longer the build. And when the build gets longer, the bugs take longer to fix, the features take longer to deploy. Every build should be minutes long, all tests included.

Now lets say, our test suite takes much longer than that. How to reduce its duration? Where to start?

Making tests become useless, converting functional tests to unit tests, running tests in parallel, building projects in parallel, doing slow tasks only once, writing fast DBMS tests... Let's share dozens of tips to fasten you test suite A LOT.

Publié dans : Technologie
  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Let's make this test suite run faster! SoftShake 2010

  1. 1. Let's make this test suite run faster!
  2. 2. Let's make this test suite run faster! Why? What for ? http://farm1.static.flickr.com/158/349497988_fb751a5e3a_z.jpg
  3. 3. You test early and often Don’t you? http://farm1.static.flickr.com/97/246816211_573c2901e1_z.jpg?zz=1
  4. 4. Continuous integration, continuous testing... ...even continuous deployment http://vator.tv/images/attachments/150609195630ctd.gif
  5. 5. Testing often Often means waiting a lot http://farm3.static.flickr.com/2505/3772118924_11fe195ef1.jpg
  6. 6. Your coding room doesn’t have to look like this What for ? http://upload.wikimedia.org/wikipedia/commons/3/3f/ Nespresso_boutique.JPG
  7. 7. Tests can be fast Even if lines of code keep growing
  8. 8. Easy! Let’s distribute across multiple hudson servers
  9. 9. It doesn’t have to be complicated I’ll share a few simple tricks
  10. 10. It can make your product better Simple to test, means simple to write, deploy and USE Photo: http://www.flickr.com/photos/zoutedrop/2317065892/
  11. 11. How can we accelerate the tests? The Cheater The Lazy The Brave http://all-the-movies.cowblog.fr/images/arton1122.jpg
  12. 12. The Cheater The Lazy The Brave http://all-the-movies.cowblog.fr/images/arton1122.jpg
  13. 13. Buy a faster machine Tests are cpu/memory bound http://farm1.static.flickr.com/28/93569705_1c562b413a_z.jpg?zz=1
  14. 14. Be warned Single threaded tests get slower over time 100 75 50 25 0 2007 2008 2009 2010 http://farm5.static.flickr.com/4096/4819945812_735744e0fc_z.jpg
  15. 15. Use all the cores parallel build with maven3 mvn -T1 clean install : 5:05s mvn -T4 clean install : 3:10s
  16. 16. Use all the cores parallel build with maven3
  17. 17. Use all the cores For JUnit/TestNG tests .
  18. 18. The Cheater The Lazy The Brave http://all-the-movies.cowblog.fr/images/arton1122.jpg
  19. 19. Delete redundant tests It’s so simple, we don’t do it... http://geekandpoke.typepad.com/geekandpoke/images/2008/04/24/ turingtest.jpg
  20. 20. Even better, delete dead code To delete yet other useless tests http://farm1.static.flickr.com/58/191393602_3d9b643ab0_z.jpg
  21. 21. Work in a sandbox The network is too slow In-memory database: H2 Behaves more like MySql than Hsqldb
  22. 22. It’s Not only SQL If going with NoSQL, take a server that can run in-process eg. Voldemort
  23. 23. In-memory SMTP Server Ethereal
  24. 24. Everything local and in-memory Files Apache VFS (Virtual File System) Spring Resource... As a bonus, tests will run smoother .
  25. 25. The Cheater The Lazy The Brave http://all-the-movies.cowblog.fr/images/arton1122.jpg
  26. 26. Don’t test business rules in integration tests Unit tests is often a better place http://upload.wikimedia.org/wikipedia/commons/b/bd/ Contortionist_Ravi_standing.jpg
  27. 27. Don’t test business rules in integration tests Unit tests is often a better place Functional test (on a web page) 10s Unit test 0.01s
  28. 28. Take the longer integration test Break it in one faster integration test and a lot of small unit tests http://farm2.static.flickr.com/1168/3166709586_96f9a3fd95.jpg
  29. 29. Or mock the slowest layers eg. functional test with Spring and Mockito
  30. 30. Or mock the slowest layers eg. functional test with Spring and Mockito Mocks are not just for unit tests
  31. 31. Don’t test through the browser Selenium is often overkill «But my application is complex!» «My users want complex features, My users want Ajax» «I need to test browser compatibility!» Photo: http://www.flickr.com/photos/zoutedrop/2317065892/
  32. 32. Really ? http://i.zdnet.com/blogs/complexity-and-false-hope.jpg
  33. 33. Complexity has a cost That you pay each time a test runs http://thehongkongfixereng.files.wordpress.com/2008/07/couteau-suisse.jpg
  34. 34. Test through the browser the strict minimal Use javascript unit tests for the rest http://farm2.static.flickr.com/1168/3166709586_96f9a3fd95.jpg
  35. 35. I tend to be old school And write server-side code most of the time http://www.celebridiot.com/wp-content/uploads/2009/06/ rick_astley_death_hoax.jpg
  36. 36. One more thing... Simplify and optimize your code Tests will run faster .
  37. 37. Thank you Q/A
  38. 38. Who am I? David Gageot CTO algodeal.com The Crowd Sourced Quant Hedge Fund @dgageot javabien.net

×