我不在乎它是怎么做的,我只想在我的测试中使用它!
useintest的Python项目详细描述
Less blurb, more documentation - link to ReadTheDocs。
主要功能
- 运行服务(例如mongo、couchdb、irods)和使用 可执行文件(如samtools、icommands)。
- 不需要容器知识。
- 不需要了解服务/可执行文件(如何安装,何时 它已经可以使用了,等等)。
- 不需要在本地计算机上安装任何东西, 除了码头工人。
- 使测试同一服务的多个版本变得简单 或一组可执行文件。
- 易于实现测试隔离。
模块
开箱即用支持:
- 蒙戈
- couchdb
- IRODS
- samtools
- Gitlab
- 护目镜
- 比塞尔
- 领事
为什么要用这个图书馆?
软件不再孤立地工作;随着 微体服务,现代应用程序依赖于 数据和计算的外部服务。
模拟可以是一种快速的方法来测试(应该)行为的东西 就像应用程序使用的外部服务一样。但是,除非 备受尊敬的嘲讽框架存在,模拟你最终会 可能会对 像你的错误代码一样服务!
用“真实的东西”或它的共享开发镜像进行测试可能是 在开发过程中不是一个好主意,特别是如果 你在使用保持状态。您希望能够在中运行测试 并行,可重复性和可用性,无论何时 您处于脱机状态,或者为组织外的协作者。你 也希望能够擦干净石板,重新开始如果 出事了!你不太可能做到 在任何一种共享的环境中。
这个库提供了一种方法来启动服务,然后抛出它们 在每个测试用例之后离开,机器上没有遗留的任何混乱。它 提供完整的测试隔离以及您正在测试的信心 提供类似于生产中使用的服务。
快速示例
启动mongo的容器化实例:
fromuseintest.modules.mongoimportMongoServiceController# Starts a containerised version of Mongocontroller=MongoServiceController()withcontroller.start_service()asservice:run_my_tests(my_application,service.host,service.port)
通过“代理”在主机的容器中使用samtools 可执行文件“:
fromuseintest.modules.samtoolsimportSamtoolsExecutablesControllercontroller=SamtoolsExecutablesController()executables_directory=controller.write_executables()# In the case of Samtools, there will be one executable in `executables_directory` named "samtools"run_my_tests(my_application,executables_directory)controller.tear_down()
文档
有关更多详细信息,包括有关如何设置和使用 图书馆,请view the documentation on ReadTheDocs或从 /docs。