testing - 如何在每个拉取请求中运行特定测试?

标签 testing phpunit pull-request bitbucket-pipelines

假设我们有超过 1500 个测试,并且在 pull-request 合并到 master 分支之前,我们有一个始终运行测试的测试管道,并且所有测试都需要超过 45 分钟要运行的测试。其中一些测试不需要一次又一次地运行,而其中一些应该运行。

我们是否有解决方案来指定哪些测试应该在哪个拉取请求中运行,哪些测试不应在特定的拉取请求中运行,或者我应该这样问。我们能否以某种方式定义过滤器以指定应在 [X] 拉取请求中运行哪些测试?

最佳答案

您应该能够配置 phpunit 为特定分支运行特定测试,例如,在下面的配置中,phpunit 将为 master 分支运行所有测试,并且仅为与主分支匹配的任何分支运行测试子集feature/* 全局模式:

pipelines:
  default:
    - step:
        name: Run all tests
        script:
          - phpunit mydir
  branches:
    master:
      - step:
          name: Run all tests
          script:
            - phpunit mydir
    'feature/*':
      - step:
          name: Run only MyTest test class
          script:
            - phpunit --filter MyTest

或者,您应该能够根据 BITBUCKET_BRANCH environment variable 决定运行哪个测试:

pipelines:
  default:
    - step:
        name: Run test that match the name of the branch
        script:
          - phpunit --filter "${BITBUCKET_BRANCH}"

关于testing - 如何在每个拉取请求中运行特定测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59057685/

相关文章:

java - 如何测试需要任务花费未定义的时间才能完成的功能

java - 编写高效且无冗余的测试

symfony - "Undefined index: localhost"使用 Symfony2 模块的 Codeception 中的 PHPUnit 异常

git - 有没有办法制作 PR 但在我的 github 帐户中将 repo 设为私有(private)?

azure - 无法使用 Azure DevOps Pull 请求对构建错误进行排队

c# - Telerik WebAii Framework - 如何将焦点更改为新打开的页面/窗口

php - php中的behat、mink和selenium有什么区别

php - 我怎样才能让 phpunit 不吞下 error_log 输出?

git - 如何修改 GitHub pull request?

java - 使用 Clock.fixed() 模拟 LocalDate.now(clock)