开发者

While running some java DB Unit tests which call a python script how can I test the code coverage for the python script?

开发者 https://www.devze.com 2023-01-17 00:09 出处:网络
I have a python script which generates some reports bas开发者_Go百科ed on a DB. I am testing the script using java Db Units which call the python script.

I have a python script which generates some reports bas开发者_Go百科ed on a DB. I am testing the script using java Db Units which call the python script. My question is how can I verify the code coverage for the python script while I am running the DB Units?


Coverage.py has an API that you can use to start and stop coverage measurement as you need.

I'm not sure how you are invoking your Python code from your Java code, but once in the Python, you can use coverage.py to measure Python execution, and then get reports on the results.

Drop me a line if you need help.


I don't know how you can check for inter-language unit test coverage. You will have to tweak the framework yourself to achieve something like this.

That said, IMHO this is a wrong approach to take for various reasons.

  1. Inter-language disqualifies the tests from being described as "unit". These are functional tests. and thereby shouldn't care about code coverage (See @Ned's comment below).
  2. If you must (unit) test the Python code then I suggest that you do it using Python. This will also solve your problem of checking for test coverage.
  3. If you do want to function test then it would be good idea to keep Python code coverage checks away from Java. This would reduce the coupling between the Java and Python code. Tests are code after all and it is usually a good idea to reduce coupling between parts.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号