Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Couverture de code

6,598 views

Published on

Découvrir une nouvelle fonctionnalité de Xcode 7 : La mesure de la couverture du code par les tests unitaires. Au moment où la taille et la complexité du code grandit, le sujet de la qualité du code et de sa maintenance devient essentiel.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Couverture de code

  1. 1. LEVERAGING XCODE CODE COVERAGE SIMONE CIVETTA - THURSDAY, 8TH OCTOBER
  2. 2. ENTRETEMPS...
  3. 3. CODE COVERAGE
  4. 4. WHAT IS CODE COVERAGE?
  5. 5. TESTING
  6. 6. METRIC THAT MEASURES THE VALUEOF YOUR TESTS
  7. 7. CODE COVERAGE DETECTS > Which code is executing when we're running the tests > Which code is untested
  8. 8. HOW DOES IT WORK? > The information is gathered in two steps 1. compile time 2. runtime > Tools count each expression that is executed
  9. 9. CODE COVERAGE ON IOS
  10. 10. CODE COVERAGE ON IOS UNTIL LAST MONTH
  11. 11. OBJECTIVE-C
  12. 12. SWIFT
  13. 13. HOW IT WORKED
  14. 14. 1. LLVM CREATES ANNOTATION FILES .gcno gcc -ftest-coverage
  15. 15. 2. LLVM CREATES DATA FILES .gcda gcc -fprofile-arcs
  16. 16. HOW TO ENABLE IN XCODE
  17. 17. HOW TO ENABLE VIA COMMAND LINE
  18. 18. GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES xcodebuild [...] test
  19. 19. TOOLS
  20. 20. TOOLS > Coverstory > gcovr > lcov > Slather
  21. 21. SLATHER Exports to: - HTML - Gutter JSON - Cobertura XML github.com/venmo/Slather
  22. 22. BUT, ALSO
  23. 23. SWIFTCOV swiftcovgithub.com/realm/SwiftCov > Supports gcov format > Uses breakpoints to gather coverage data
  24. 24. CODE COVERAGE ON IOS
  25. 25. CODE COVERAGE ON IOS SINCE LAST MONTH
  26. 26. OBJECTIVE-C
  27. 27. SWIFT
  28. 28. A NEW FORMAT> gcov > profdata
  29. 29. XCODE GENERATES profdata FILES FOR > Swift > ...and Objective-C
  30. 30. HOW TO ENABLE IN XCODE
  31. 31. HOW TO ENABLE VIA COMMAND LINE
  32. 32. xcodebuild [...] test -enableCodeCoverage YES
  33. 33. xcodebuild -scheme MoDevByProject -destination "name=iPhone 6,OS=latest" -enableCodeCoverage YES test
  34. 34. EXPLOITING THE DATA > llvm-cov > llvm-cov show
  35. 35. HOW TO USE LLVM-COV $XCODE_PATH/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-cov show -instr-profile MY_PROJECT_PROFDATA MY_PROJECT_BINARY_FILE
  36. 36. TOOLS
  37. 37. TOOLS > Slather > Xcode Server
  38. 38. SLATHER github.com/venmo/slather/pull/92
  39. 39. XCODE SERVER
  40. 40. SUMMING UP
  41. 41. DOESN'T TELL YOU IF YOUR CODE IS BAD...
  42. 42. DOESN'T TELL YOU IF YOUR CODE IS BADBUT CAN HELP WRITING BETTER CODE
  43. 43. YOU'RE JUST MINUTES AWAY FROM COLLECTING CODE COVERAGE INFO FOR SWIFTSTART SOON!
  44. 44. THANK YOU
  45. 45. Simone Civetta @viteinfinite
  46. 46. XEBICON

×