如何在Python中集成travisci和codelime测试覆盖率?

2024-05-15 13:22:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让我的Travis CI将测试覆盖率数据发送到codecompature服务,但是关于codecompature和Travis CI的文档并没有详细描述如何使用Python实现这一点。根据代码气候和Travis文档,仍然支持它的特性。我试着在这上面找到任何有用的例子,但是运气不好,我自己也无法做到。在

代码气候文档: Setting Up Test CoverageReadme: codeclimate-test-reporter

Travis CI文档: Using Code Climate with Travis CI

我已经在Travis CI中设置了codeClemate_REPO_令牌,如下所述: https://stackoverflow.com/a/31281481/1754089

我的。特拉维斯·伊梅尔文件:

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-tu成功线太多了,因此在日志视图中可以看到:

^{pr2}$

Tags: installpiprun代码文档pytesttravis
2条回答

所以事实上,在你看来,这只是彼得在评论中提到的那种类型的问题。你的after_success应该有codeclimate-test-reporter-看起来你有,但是travis报告了其他事情。在

现在来看看我为什么要开赏金,为什么实际上只是我不明白codecalmate_test_reporter是如何工作的。我想报告我的报道py.测试. codeclimate_test_reporter在GitHub上有一个相当不错的自述文件,显示了how to create a coverage report。然而,从他们的例子来看,提供codelimetest reporter作为cov的参数将自动向codeliamte发送报告。事实并非如此

使用py.测试,您要做的是:

script:
- py.test  cov=YourModuleYouWantToCover test_folder
- codeclimate-test-reporter  file .coverage

奇迹发生了,第一次,我有一个关于共同气候的报道!在

编辑:我向codelime test reporter提交了一个pull请求来更新他们的自述文件,它已经被合并了,所以希望以后的人们少一些困惑!在

CodeClimatePython测试报告器已经被弃用。可以在https://github.com/codeclimate/test-reporter/blob/master/examples/python_examples.md找到使用travis ci处理python测试报告的更新方法

相关问题 更多 >