用于测试软件库api相似性的集成测试框架。

doppel-cli的Python项目详细描述


doppel cli

PyPI VersionTravis Build StatusAppVeyor Build StatusDocumentation StatuscodecovPython Versionsdownloadslicense

doppel-cli是一个集成测试框架,用于测试跨语言的api相似性。

保持相同的公共接口有什么价值?

此项目测试跨语言库中的API一致性

为什么这么值钱?

  • 对于开发人员:
    • 减少跨语言实现更改的通信开销
    • 强制函数限制公共API
    • 复杂性的增长
  • 对于用户:
    • 切换语言时无需重新学习API
    • 在转换语言时形成更好的期望

文件

有关最新的文档,请参见https://doppel-cli.readthedocs.io/en/latest/

入门

doppel-cli可以像任何其他python包一样从源代码安装。

python setup.py install

您还可以从pypi安装,python的官方包管理器。为了避免与存储库上的现有项目相关联的冲突,它被分配为。

pip install doppel-cli

示例:测试r和python实现之间的连续性

在本例中,我将展示如何使用doppel来测试同一api的r和python实现之间的连续性。在这个例子中,我使用了argparse库。

注意:本例假设您已经在本地安装了argparse

如果不运行其中一个或两个:

Rscript -e "install.packages('argparse')"
pip install argparse

首先,您需要生成doppel用于存储有关项目api的信息的特殊文件。这些是使用doppel-describe工具创建的。

PACKAGE=argparse

# The R package
doppel-describe \
    -p ${PACKAGE} \
    --language R \
    --data-dir $(pwd)/test_data

# The python package
doppel-describe \
    -p ${PACKAGE} \
    --language python \
    --data-dir $(pwd)/test_data

太酷了!让我们做些测试!doppel-test可用于比较多个包。

doppel-test \
    --files $(pwd)/test_data/python_${PACKAGE}.json,$(pwd)/test_data/r_${PACKAGE}.json \
    | tee out.log \
    | cat

这将产生如下结果:

Function Count
==============
+---------------------+----------------+
|   argparse [python] |   argparse [r] |
+=====================+================+
|                   0 |              1 |
+---------------------+----------------+


Function Names
==============
+-----------------+---------------------+----------------+
| function_name   | argparse [python]   | argparse [r]   |
+=================+=====================+================+
| ArgumentParser  | no                  | yes            |
+-----------------+---------------------+----------------+

Function Argument Names
=======================
No shared functions.

Class Count
===========
+---------------------+----------------+
|   argparse [python] |   argparse [r] |
+=====================+================+
|                   9 |              0 |
+---------------------+----------------+


Class Names
===========
+-------------------------------+---------------------+----------------+
| class_name                    | argparse [python]   | argparse [r]   |
+===============================+=====================+================+
| MetavarTypeHelpFormatter      | yes                 | no             |
+-------------------------------+---------------------+----------------+
| ArgumentParser                | yes                 | no             |
+-------------------------------+---------------------+----------------+
| FileType                      | yes                 | no             |
+-------------------------------+---------------------+----------------+
| HelpFormatter                 | yes                 | no             |
+-------------------------------+---------------------+----------------+
| RawDescriptionHelpFormatter   | yes                 | no             |
+-------------------------------+---------------------+----------------+
| Action                        | yes                 | no             |
+-------------------------------+---------------------+----------------+
| ArgumentDefaultsHelpFormatter | yes                 | no             |
+-------------------------------+---------------------+----------------+
| Namespace                     | yes                 | no             |
+-------------------------------+---------------------+----------------+
| RawTextHelpFormatter          | yes                 | no             |
+-------------------------------+---------------------+----------------+


Class Public Methods
====================
No shared classes.

Arguments in Class Public Methods
=================================
No shared classes.

Test Failures (12)
===================
1. Function 'ngettext()' is not exported by all packages

2. Function 'ArgumentParser()' is not exported by all packages

3. Packages have different counts of exported classes! argparse [python] (9), argparse [r] (0)

4. Class 'HelpFormatter()' is not exported by all packages

5. Class 'Namespace()' is not exported by all packages

6. Class 'RawDescriptionHelpFormatter()' is not exported by all packages

7. Class 'ArgumentParser()' is not exported by all packages

8. Class 'MetavarTypeHelpFormatter()' is not exported by all packages

9. Class 'Action()' is not exported by all packages

10. Class 'ArgumentDefaultsHelpFormatter()' is not exported by all packages

11. Class 'FileType()' is not exported by all packages

12. Class 'RawTextHelpFormatter()' is not exported by all packages

如上所示,argparsepython包有9个导出类,而r包没有。

doppel的角度来看,这被视为测试失败。如果在终端中运行echo $?,应该会看到1打印出来。像这样返回一个非零的退出代码告诉CI工具,比如Travis,测试是一个失败,使得^ {CD3}}对CI很有用(在将来的例子中更多关于这个)。

你可能会想“好吧,等等,你肯定想测试更多的东西,而不仅仅是类和函数的计数,对吧?”完全正确!请参阅the project issues issues以获取我要添加的积压功能欢迎您的加入!!!

要了解有关当前可配置的内容的更多信息,您可以运行:

doppel-describe --help

以及

doppel-test --help

贡献

错误报告、问题和功能请求应该指向the issues page

有关如何贡献的信息,请参见CONTRIBUTING.md

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何克服带有空值的不可空bean级验证   “此行有多个标记”的authenticateUser上的java MySQLConnection错误   java处理Jackson异常   java Netbeans编辑器如何知道文件在撤消后不会被修改?   目标C相当于Java的ArrayList   java当需要int时,可以将short传递给方法调用吗?   drawString()方法上的java MouseListener   java服务器socket是执行此操作的最佳选项   java需要单个匹配bean,但找到了2:org。springframework。网状物servlet。mvc。方法注释。RequestMappingHandlerMapping   如何在Java中执行Windows命令?   安卓应用程序的java文件主机   java将所有spring引导属性都设置在内。将yml文件转换为系统属性   Java邮件中的html内联链接在邮件客户端中不起作用   Java二进制文件的bazel版本控制   java如何在自定义ListView中使用Intent   java(Spring MVC+Hibernate 4+Test 4)自动连线DAO返回NULL   java一次add()调用可以在Solr服务器中索引多少文档?   java如何获取Avro GenericRecord大小