Skip to content

Files

Latest commit

 

History

History

unit_test

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

About

這裡記錄了學習 Flutter - Dart 如何進行 Unit test 的方法。

More information: https://flutter.dev/docs/cookbook/testing

⚾ Unit Test

test functions

  • Basic testing: 一些最基本的語法,expect, contains, start/endsWith 等等

  • Setup testing: 學習怎麼樣在 test 前 setup 一些物件,並在結束時 teardown

  • Asynchronous testing: unit test 最重要的部分,如果搭配 Future, Stream, .. 和不一樣的 emit 與 expect 語法來進行測試

  • 以上參考官方所提供的文件

Mockito

  • Adding Dependency
dev_dependencies:
  mockito: ^4.0.0

⚽ Widget Test

  • Basic Widget testing: 在 testWidget 環境下利用 pumpWidget 生成 widget ,並且使用 find 和 expect 查看是否有此元件

  • Finding widget: Flutter 提供多種方式來查找 widget

  • Interact with widget: 找到 widget 之後,就可以對該 widget 進行 tap, drag, input 等各種測試

🏀 Integration Test

  • Adding Dependency
dev_dependencies:
  flutter_driver:
    sdk: flutter

🎱 CI/CD Tool - CodeMagic