我试图让我的Travis CI将测试覆盖率数据发送到Code Climate服务,但Code Climate和Travis CI的文档没有详细描述如何使用Python执行此操作。根据Code Climate和Travis文档,它仍然是其支持的功能。我试图在没有运气的情况下找到任何有关这方面的工作示例,并且不能让它自己运作。
Code Climate文档: Setting Up Test Coverage, Readme: codeclimate-test-reporter
Travis CI文档: Using Code Climate with Travis CI
我已按照此答案中的说明在Travis CI中设置了CODECLIMATE_REPO_TOKEN: https://stackoverflow.com/a/31281481/1754089
我的.travis.yml文件:
language: python
python:
- 2.7
install:
- pip install -r requirements.txt
- pip install coverage
- pip install codeclimate-test-reporter
#commands to run tests:
script:
- python mytests.py
- coverage run mytests.py
after_success:
- codeclimate-test-reporter
因为Travis中的after_success行已经超出了它,所以在日志视图中给出了这个:
/home/travis/build.sh: line 45: codeclimate-test_reporter: command not found
答案 0 :(得分:5)
所以确实看起来像你在评论中提到的那种类型的问题。您的after_success
应该有codeclimate-test-reporter
- 看起来您已经拥有它,但是travis正在报告其他内容。
现在为什么我开了一个赏金,为什么实际上只是我不理解codeclimate_test_reporter是如何工作的。我想从py.test报告我的报道。 codeclimate_test_reporter在GitHub上有一个非常自述的显示how to create a coverage report。然而,从他们的例子来看,它似乎提供了codeclimate-test-reporter作为参数--cov会自动向codecliamte发送报告。情况并非如此
使用py.test,你想要做的是:
script:
- py.test --cov=YourModuleYouWantToCover test_folder
- codeclimate-test-reporter --file .coverage
魔术发生了,我第一次有关于codeclimate的报道报道!
编辑:我向codeclimate-test-reporter提交了一个拉取请求来更新他们的自述文件并且已经合并,所以希望对未来人们的混淆更少!
答案 1 :(得分:0)
此代码环境python-test-reporter已被弃用。可以在https://github.com/codeclimate/test-reporter/blob/master/examples/python_examples.md
中找到使用travis-ci处理python测试报告的更新方法。