Honey E2E Testing in Flutter. This honey is good to eat and sweet.
這篇寫於 2023 年。工具和 API 變化很快,部分步驟可能已經不適用。
New HoneyTalk language for testing
Honey is a great package. I have been paying attention to it since it was released. I tried it out recently. I feel that it is very simple for developers, and it is also very helpful for non-engineers. It only needs to be written through ordinary spoken sentences Test and verify the processes and scenarios most frequently operated by users, so that the quality of our APP is more guaranteed. Come and play now~
Introduction#
- E2E Test framework
- The author is the developer of ClickUp, a well-known open-source contributor
- Use HoneyTalk language with sentences to write tests, even non-engineers can participate, no need to understand implementation details
- The default is asynchronous, no need to wait for time-consuming operations and animations
- Provide Accessibility Tree to view the visual information of each component, including attributes, positions, and sizes
- Other works are Hive, Isar, and other suites
Installation#
dependencies:
...
honey: <latest-version>
Setup#
In the main() method, use environment variables to determine whether to execute Honey initialization, using HoneyWidgetsBinding.
void main() {
const kIsHoney = bool.fromEnvironment('HONEY');
if (kIsHoney) {
HoneyWidgetsBinding.ensureInitialized();
}
runApp(const MyApp());
}
Write Test#
Create a new honey folder in the root directory, and the extension of each test file is named .honey
Verify Text#
seeexpect thatverify thatmake sure thatassert thatlook that
verify that "0" is visible
Tap Button#
tapclickhit
Input Text#
entertype
Swipe#
swipeslidescroll
swipe left "list" by 100
Call Functions#
autoLogin()
tap "Action" button
verify "New note" is visible
Conditions#
if "button" is visible then
print "hello"
else
print "world"
endif
The example of this article provides two pages. We write a custom test process. The main page is the original counter, and the second page displays some text.
tap "Increment" button
verify that "1" is visible
click "Increment" button
make sure that "2" is visible
expect that "3" is not visible
click "Second" button
expect that "Second" is visible
expect that "Hello world" is visible
Run#
VSCode Configuration
VSCode Extension#
Install the VSCode plugin, search the keyword Honey, support the writing of HoneyTalk language, and help highlight the keywords used.
Demo#
Weakness#
- Not long after it was released, the documents were not complete
- The premise of writing a test requires the ability to communicate in English, and the grammar is correct to write a good test
Source Code#
- Flutter CICD 使用 Gitlab Runner 和 App Center 實作 part.1
- 使用 CodeMagic 和 Firebase 實現 Flutter CICD
- 輕鬆完成Flutter開發環境,最新版!
- 實作Flutter多變有趣的滾動效果CustomScrollView!
- 如何在Flutter使用 Makefile 節省你的時間?
- Easily understand StatefulWidget LifeCycle of Flutter
- “freezed” makes model class strong and easily
- 提高Flutter性能的小技巧!(一)
- 提高Flutter性能的小技巧!(二)
- 提高Flutter性能的小技巧!(三)
- What are Async and Isolates in Flutter?
- LoadBalancer is optimization for Isolates in Flutter
- Riverpod 輕鬆學,原來這麼好用!
- Riverpod 輕鬆學(二),一些進階用法!
About#
- GitHub: chyiiiiiiiiiiii
- Instagram: flutterluvr.yii
- Linkedin: yiichenhi
- Youtube: Yii
- Youtube: 一起饅頭(美食頻道)
- Email: ab20803@gmail.com
Contribute#
Thank you for taking the time to read it. If you feel good, you can donate. It will give me more motivation and enthusiasm to share more interesting content! Buy me a cup of coffee~
End#
Follow me to get the latest articles.
本文原刊登於 Medium。