Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AndroidCodeCoverage.pdf

76655285ce09413e5e739ecb60add953?s=47 Michal Jenicek
October 12, 2018
35

 AndroidCodeCoverage.pdf

76655285ce09413e5e739ecb60add953?s=128

Michal Jenicek

October 12, 2018
Tweet

Transcript

  1. ANDROID CODE COVERAGE Michal Jeníček, Android Engineer at STRV

  2. !2 “Code coverage is not your enemy. It’s a tool

    to help you with development.“
  3. JACOCO JAVA CODE COVERAGE !3 • Based on byte code,

    thus is for Kotlin too
  4. MISSED INSTRUCTIONS & BRANCHES !4 • JaCoCo offers two main

    metrics
  5. CODE COVERAGE SAMPLE !5

  6. !6

  7. !7

  8. !8

  9. !9

  10. !10

  11. !11

  12. CODE COVERAGE - DOES IT WORTH? !12 Code coverage analysis

    will • Help to find missing branches in unit testing • Help to keep in mind when there will be decreasing coverage with new code Code coverage analysis will NOT • Ensure, you have been writing tests right
  13. CODE COVERAGE - WHEN TO USE !13 Whenever tests are

    written • It’s small effort to get helpful tool useful for checking our tests Whenever tests are executed on CI • It’s small effort to connect code coverage to continuous integration
  14. RUN CODE COVERAGE !14

  15. Intellij IDEA !15 • Analyse simple project locally (no standard

    outputs)
  16. GRADLE PLUGIN DEFAULT TASK !16 • Analyse simple project for

    CI (instrumentation only)
  17. GRADLE PLUGIN CUSTOM TASK !17 • Analyse complex project for

    CI
  18. UNIT TEST ANALYSIS !18

  19. !19

  20. !20

  21. !21

  22. !22

  23. !23

  24. !24

  25. CI GIT INTEGRATION !25

  26. CI BRANCH CHECKS !26 • Run checks with every push

    to branch automatically • Merge pull request / branch based on available checks
  27. CIRCLE CI 2.0 !27

  28. CIRCLE CI 2.0 !28

  29. CIRCLE CI 2.0 !29

  30. CIRCLE CI 2.0 !30

  31. TRAVIS CI !31

  32. TRAVIS CI !32

  33. TRAVIS CI !33

  34. TRAVIS CI !34

  35. JENKINS PIPELINE !35

  36. JENKINS PIPELINE !36

  37. JENKINS PIPELINE !37

  38. !38 JENKINS UI

  39. CODE COVERAGE OUTPUTS !39

  40. OUTPUTS STRUCTURE !40

  41. OUTPUTS STRUCTURE !41

  42. OUTPUTS STRUCTURE !42

  43. OUTPUTS STRUCTURE !43

  44. JACOCO LOCAL !44

  45. JACOCO LOCAL !45

  46. CODECOV !46

  47. SAMPLE PROJECT !47

  48. I have prepared stub of sample application to apply all

    kinds of code coverage ability. Sample application is built following way: • Single activity multi-module application • Navigation architecture component • MVVM approach • DI with Dagger • Connected to Travis, Circle CI, Jenkins CI & Codecov !48 HTTPS://GITHUB.COM/KOTOMISAK/IMAGE-ANALYZER-ANDROID
  49. THAT'S IT Michal Jeníček michal.jenicek@strv.com

  50. QUESTIONS