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

Intro to Unit Test & Metrics

Intro to Unit Test & Metrics

Maikel Chandika

July 28, 2018
Tweet

More Decks by Maikel Chandika

Other Decks in Programming

Transcript

  1. Maikel Chandika, S.Kom, OCA  ICT Manager and Lead Java

    Developer at Waruna Group  Java Ecosystem and OSS Enthusiast  Website: https://mkdika.com  GitHub: mkdika 2
  2. Todays Topics A Little Bite to Software Testing Java Testing

    Framework & Libs Unit Test Metrics & Demo To go further 3
  3. Test Framework & Lib in Java  Testing Framework: JUnit,

    TestNG, JBehave  Mock Lib: Mockito, PowerMock, EasyMock  Parameterized Test Lib: JUnitParams  Equality Test Lib: Hamcrest  Integration Test Lib: Maven Failsafe, REST Assured, DBUnit 7
  4. Unit Test Metric & Analysist Lib  Built System &

    Test env: Maven, Gradle  Code Coverage Lib: Jacoco, Cobertura  Mutation Test Lib: PIT  Load Test Tools: JMeter, Gatling  End-to-End/ Acceptance Test Tools: Cucumber 8
  5. Test Metrics – Coverage Test “A measure used to describe

    the degree to which the source code of a program is executed when a particular test suite runs.” 10
  6. Test Metrics – Coverage Test? Percentage of our code call

    (statement, branch, path) from test environment. Not say anything about quality of our test. 11
  7. Test Metrics – Mutation Test 13 “Test how good are

    your Unit Test.” Add mutation (errors) to the code and check if unit test failed (fault seeding). Effectiveness of test is gauged by ratio of survived and killed mutations.
  8. Test Metrics – Mutation Test? 14 Very CPU demanding &

    time consuming process. Will slow down review life cycle if run in every single commit.
  9. What Next?  Unit test best practice  Mock Test

     Integration Test  Test-driven Development (TDD)  Behavior-driven Development (BDD)  Automatic Static Code Analysis ex: Findbugs 15 Cucumber BDD Example
  10. Other PL Unit Test Framework & Libs  PHP 

    Unit test & coverage: PHPUnit  Mutation test: Humbug  .NET  Unit test & coverage: MS Test, Nunit  Mutation test: VisualMutator, NinjaTurtle  Ruby  Unit test & coverage: RSpec  Mutation test: Mutant-RSpec  Python  Unit test & coverage: unittest, coverage  Mutation test: MutPy 16
  11. Summary – Unit Test Metrics Coverage Test Numbers of code

    call from test environment (unit test). Mutation Test Test the quality of Unit Test. 17