Reputation: 3757
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.
Upvotes: 3
Views: 663
Reputation: 375574
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.
Upvotes: 1
Reputation: 95334
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).
Upvotes: 1