Code Coverage by Sachin Vas

Code Coverage by Sachin Vas

Swift Bangalore Chapter #18

Eeb061c8b2816b771920da1b3e7904a3?s=128

Swift India

October 19, 2019
Tweet

Transcript

  1. CODE COVERAGE Sachin Vas, Halodoc

  2. None
  3. AGENDA ▸ CI/CD PIPELINES ▸ CODE COVERAGE ▸ XCODE IDE

    SUPPORT ▸ LLVM CODE COVERAGE
  4. Code Merge Build Unit Test Integration Test Code Review Staging

    Production CI Pipeline CD Pipeline
  5. CI/CD ▸ Merges changes to main branch as often as

    possible ▸ Validates changes using automated tests ▸ Added advantage over delayed merges which usually ends up in integration hell ▸ Always checks newer commits doesn’t break any of the existing code CI PIPELINE
  6. CI/CD ▸ Extension on the previous step ▸ Release new

    changes quickly in a sustainable way ▸ Deploy at your convenience time (daily, weekly, fortnightly) ▸ Best practice is to rollout updates in small batches for ease troubleshooting any production issues. ▸ Continuous Deployment is the automatic version of Continuous Delivery. CD PIPELINE
  7. CODE COVERAGE ▸ What ▸ Why ▸ How ▸ Types

    CODE COVERAGE
  8. CODE COVERAGE ▸ Percentage of code covered by automated tests

    ▸ Determines which statements are executed ▸ Part of feedback loop WHAT?
  9. CODE COVERAGE ▸ Our tests actually test our code ▸

    Do we have enough testing in place ▸ Maintain Test Quality over the lifetime of a project WHY?
  10. CODE COVERAGE ▸ Source Code Instrumentation ▸ Intermediate Code Instrumentation

    ▸ Runtime Information collection HOW?
  11. CODE COVERAGE ▸ Statement ▸ Branch ▸ Function TYPES

  12. CODE COVERAGE CODE COVERAGE PERCENTAGE

  13. CODE COVERAGE ▸ Built into the IDE ▸ Provides line

    coverage metrics ▸ You can exercise your frameworks (only open source files) ▸ You can customise running certain TestBundles on Certain Targets XCODE CODE COVERAGE
  14. CODE COVERAGE DEMO

  15. LLVM-COV ▸ llvm-cov ▸ Provides 4 types of code coverage

    ▸ Sub commands for meaningful statistics ▸ Custom script to generate coverage ▸ Provides similar reports as Jacuco. LLVM CODE COVERAGE
  16. LLVM-COV ▸ llvm-profdata ▸ Merge multiple Profile Data Files ▸

    Useful if you have multiple in-house frameworks LLVM PROFDATA COVERAGE
  17. LLVM-COV DEMO

  18. CODE COVERAGE ▸ Ensure every Public Method is covered ▸

    Increase Code Coverage for each Public Method ▸ Cover Conditionals ▸ Prefer Branch Coverage over other types RECOMMENDATION
  19. CODE COVERAGE https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/testing_with_xcode/chapters/ 07-code_coverage.html https://clang.llvm.org/docs/SourceBasedCodeCoverage.html https://llvm.org/docs/CommandGuide/llvm-cov.html https://llvm.org/docs/CommandGuide/llvm-profdata.html REFERENCES