Hot Reload during Unit testing

淺唱寂寞╮ 提交于 2019-12-24 20:54:48

问题


I develop right now a small flutter app. I think as everyone, I fell in love with the hot reload feature.

So now I'm wondering if there is any possibility to have the same developer experience during unit test. Do have to turn a flag somewhere or is it right know just no possible.

If is not possible, are there any plans to make it possible?


回答1:


I guess what you want is to run the new tests as soon as they changed. But in that case it's not a hot reload. Simply a watcher that detect whenever your sources or your tests have changed and restart them.

Flutter, and the lower layers, don't implement "watch" yet. Although you can achieve a similar effect quite easily using a node packages

npm i -g watch which will install watch globally so that you can use it in as a command line.

and then in your terminal do

watch "flutter test" lib test which will run flutter test everytime something change inside lib and test folders




回答2:


You need to run the unit test as an app to be able to use hot reload.

In IntelliJ you can copy the run configuration for lib/main.dart and then select the file test/my_test.dart in the copy.

There is no support to run single tests from a set of tests in a test file in IntelliJ (don't know other IDEs) when you run a test this way.

In my opinion, if you run it as unit test, hot reload doesn't bring much benefit anyway because execution is very fast.



来源:https://stackoverflow.com/questions/49004259/hot-reload-during-unit-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!