Jython 测试覆盖率

发布于 2024-09-27 01:09:22 字数 439 浏览 0 评论 0原文

我正在尝试在一个项目中使用 Jython 而不是 Python(想要一种罕见数据库的 jdbc 驱动程序)。 到目前为止一切正常,但我找不到任何好的代码覆盖率工具。有人有解决办法吗?

我所做的谷歌搜索似乎表明 jython 缺少代码覆盖工具需要的一些东西。 http://nedbatchelder.com/blog/201005/coveragepy_on_jython.html

别人是怎么解决的这?我想像 jpype 与普通 python 一起使用将是一种前进的方式,但我宁愿不在我的中引入 jpype仅用于覆盖测量的环境。

I'm trying to use Jython instead of Python for a project (want jdbc driver for a sort of rare database).
Everything is working OK so far, but I can't find any good tools for code coverage. Does anyone have a solution to this?

The googling I've done seems to indicate that jython is missing some things that code coverage tools need. http://nedbatchelder.com/blog/201005/coveragepy_on_jython.html

How do others solve this? I suppose something like jpype together with normal python would be a way forward, but I would rather not introduce jpype in my environment just for coverage measurements.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

英雄似剑 2024-10-04 01:09:22

您链接的博客文章提到您可以在 Jython 下运行“coverage run”,然后在 CPython 下运行“coverage html”。你尝试过这个吗?它应该给出合理的结果。

The blog post you link mentions that you can run "coverage run" under Jython, then "coverage html" under CPython. Did you try this? It should give reasonable results.

难以启齿的温柔 2024-10-04 01:09:22

其他人如何解决这个问题?

您的问题从根本上来说是:“我如何才能获得没有内置工具支持的语言的工具?”编程语言的超现代解决方案是尝试将所有必要的支持构建到特定的语言实现中(反射、分析、元编程等)。虽然这是一个好主意,但实现它所需的工程量是巨大的,并且......它通常不会发生(见证您与 Jython 的问题)。

解决问题的另一种方法是跳出语言(或其实现)并从旨在跨多种语言实现工具的引擎中获取工具构建支持。这也需要工程设计,但可以通过非常通用的方式来完成,以便元工具可以广泛使用。这样的元工具可以用来实现您没有的工具。

我们的DMS Software Reengineering Toolkit就是这样一个元工具,提供程序解析、分析、和转换,由显式语言定义参数化。 DMS 支持多种语言(C、C++、C#、COBOL、Java、PHP...),包括 Python,并且支持方言,使其能够处理“标准”语言的变体(我怀疑 Jython 并不完全是 Python)。

在此链接中,您可以找到一篇技术论文,介绍如何使用 DMS 等元工具实现任意语言的测试覆盖率。这个想法已被用来实现我公司提供的一系列测试覆盖工具。 (我们可能会在未来的某个时候为 Python 这样做)。

How do others solve this?

Your question is fundamentally, "how can I get tools for languages that don't have built-in tool support?" The hypermodern solution for programming langauges is to try to build in all the necessary support into the particular langauge implementations (reflection, profiling, metaprogramming, ...). While its a nice idea, the amount of engineering required to do it is huge, and .... it often doesn't happen (witness your issue with Jython).

Another way to solve the problem is to step outside the language (or its implementation) and get meta tool building support from engines that are designed to implement tools across a wide variety of languages. That requires engineering, too, but it can be done in pretty general way so that the meta-tool is widely usable. Such meta tools can then be used to implement the tools you don't have.

Our DMS Software Reengineering Toolkit is such a meta tool, providing program parsing, analysis, and transformation, parameterized by explicit langauge definitions. DMS has support for many languages (C, C++, C#, COBOL, Java, PHP, ...) including Python, and it supports dialects, enabling it to handle variations on the "standard" langauge (I suspect Jython is not exactly Python).

At this link you can find a technical paper on how a meta-tool like DMS can be used to implement test coverage for arbitrary langauges. This idea has been used to implement a family of test coverage tools available from my company. (We're likely to do this for Python at some point in the future).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文