How to test dart pub lib package before deploy?

戏子无情 提交于 2019-12-25 01:44:46

问题


what is the best way to test a pub lib package before deploy, as if I had downloaded it via pub install? (not talking about unit tests)


回答1:


You can use path packages. Instead of going through a pub server this will fetch the package from the local filesystem.




回答2:


It very much depends on the type of package you are looking to use.

If the pub package is primarily a non-UI library then you should be able to exercise its API via a UnitTest script, a small script that has a main to kick off a bunch of unit tests (grouped or otherwise).

Another option for a non-UI package is to find the source project (usually noted in the package's page on pub.dartlang.org) and download it, where if you're lucky there will be a test directory with a unit test script in it.

Some UI providing packages do include unit tests in their project too.

A lot of projects include an example or two you can run to see how it works and pick up some tips from their source code, so I encourage you to check out the original source of the project you're interested in.

But generally (especially for UI providing packages), you're going to get best results by creating a small skeleton app for the purpose of playing with the package and then apply what you learn to your main application.

Hope that helps.



来源:https://stackoverflow.com/questions/17422956/how-to-test-dart-pub-lib-package-before-deploy

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