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

Flutter Test Pyramid

Flutter Test Pyramid

Chandrasekar Kuppusamy

January 25, 2020
Tweet

More Decks by Chandrasekar Kuppusamy

Other Decks in Programming

Transcript

  1. Ground Rules Feel free to stop us if you don’t

    understand something Let’s keep it interactive No question is silly
  2. Different kinds of tests Unit Tests UI Tests Integration Tests

    Functional Tests Snapshot Tests * Contract Tests * Performance Tests
  3. Comparison of Various Types Of Tests Speed Feedback Cycle Confidence

    Flakiness/Dep endencies Cost of Maintenance Unit Fast Fast Low Low Low Integration Fast Fast Medium Medium Medium Functional Slow Slow High High High
  4. Principles of Test Distribution Based on the trade-offs, an ideal

    test distribution should optimize for * Maximum Unit tests * Sufficient Functional tests to cover important app flows Required number integration tests When we do this, the shape of test distribution generally turns out to be a PYRAMID
  5. Before We Dive Into Code Let’s understand the importance of

    App Architecture in achieving test pyramid
  6. Application Architecture & Test Pyramid Layering your app correctly using

    SOLID principles makes achieving the right test pyramid
  7. Common Architecture Anti-patterns - Difficulty In Testing Logic code in

    UI classes UI classes hard & slow to test Lack Of Dependency Injection - We end up integration testing instead of unit - Test setup becomes difficult
  8. Sample App Architecture - Single Responsibility Principle - Dependency Inversion

    - bLoc pattern with Reactive State Management - Dependency Injection - Clean Architecture Layers - data, domain, presentation
  9. A.

  10. Widget Tests - ProductListTest - What to test [branch widget_test_1]

    - ProductListItemTest - What to test [branch widget_test2] - ProductListScreenTest - What to test [branch widget_test3]
  11. Integration Tests Actually they are Functional Tests - They require

    a real device to run on - They are much slower - Multiple tests in a _test file depend on each other in terms previous state - Hard to change application setup from test file - Hard to debug failing test. Error messages not descriptive enough
  12. Golden File Tests Q. When to use Golden File Tests

    A. Keep it minimal. Test only critical functionality where alignment/size of UI controls could be a make or break scenario. a. [Should Test] Add To Cart button size as without this you get no money b. [Should Not Test] Profile page - They can be flaky as even 1px misalignment causes failure - Need to maintain golden images in CI which can increase repo size [branch golden_test_1]
  13. References Talk to Us On Gitter -> https://gitter.im/gdg-flutter-test-pyramid/community See The

    Code Here -> https://github.com/sayeedhussain/flutter_test_pyramid_gdg Thank You