Cypress 与 DevOps 的集成
Cypress Integration with DevOps
What I want to achieve:
我在 Azure DevOps 上有一个存储库,用于托管我的 Web 应用程序。我使用 Cypress 为 UI Automation 编写了一个测试套件。我为我的测试用例创建了一个单独的存储库,以检查它们是否正常工作。我创建了一个包含以下内容的管道:
trigger:
- manual-tests
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- task: Npm@1
inputs:
command: 'custom'
customCommand: 'run test'
continueOnError: true
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-output-*.xml'
testRunTitle: 'My Test Cases'
我将触发器设置为存储库的一个分支,其中存储了我的 UI 自动化代码。我想要的是,当对 Web 应用程序存储库的某个分支进行推送时,触发我的自动化脚本。有没有办法做到这一点?我们可以将我们的测试用例文件存储在应用程序存储库中并给出测试脚本的路径吗?
UI Automation Repo
和 Web Application Repo
似乎是两个独立的存储库。
To trigger my automation script, when there is a push on some branch of the web application repository. Is there a way of doing this?
功能:“从不同的存储库触发管道”现在不可用。
此功能仍在开发中。 YAML 管道的多存储库支持将很快用于 azure devops 服务。
请检查功能:Azure DevOps Feature Timeline 2020 Q2中的“YAML 管道的多存储库支持”。此功能将于 2020 年 7 月底向所有人推出。
解决方法:
您可以尝试使用 Pipeline triggers。
步骤如下:
第一步:创建一个带有web应用仓库的管道,然后你可以设置触发分支。
第 2 步:在 Yaml 文件中添加管道触发器(UI Automation Repo)。
例如:
resources:
pipelines:
- pipeline: Name
source: Pipeline name
trigger:
branches:
- releases/*
- master
当您在网络应用程序存储库中进行更改时,将触发网络应用程序的管道。
在 运行 管道之后,将触发带有 UI 自动化回购的管道。
Can we store our test case files in the application repository and give the path of the test script?
当然。你可以的。
如果你想在管道中使用测试文件(UI Automation repo),你可以在管道中添加 repo resouces。
例如:
resources:
repositories:
- repository: MyAzureReposGitRepository
type: git
name: MyProject/WebapplicationRepo
...
steps:
- checkout: MyAzureReposGitRepository
注意:回购将检出到代理源文件夹。
希望对您有所帮助。
What I want to achieve:
我在 Azure DevOps 上有一个存储库,用于托管我的 Web 应用程序。我使用 Cypress 为 UI Automation 编写了一个测试套件。我为我的测试用例创建了一个单独的存储库,以检查它们是否正常工作。我创建了一个包含以下内容的管道:
trigger:
- manual-tests
pool:
vmImage: 'ubuntu-latest'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- script: |
npm install
displayName: 'npm install'
- task: Npm@1
inputs:
command: 'custom'
customCommand: 'run test'
continueOnError: true
- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: '**/test-output-*.xml'
testRunTitle: 'My Test Cases'
我将触发器设置为存储库的一个分支,其中存储了我的 UI 自动化代码。我想要的是,当对 Web 应用程序存储库的某个分支进行推送时,触发我的自动化脚本。有没有办法做到这一点?我们可以将我们的测试用例文件存储在应用程序存储库中并给出测试脚本的路径吗?
UI Automation Repo
和 Web Application Repo
似乎是两个独立的存储库。
To trigger my automation script, when there is a push on some branch of the web application repository. Is there a way of doing this?
功能:“从不同的存储库触发管道”现在不可用。
此功能仍在开发中。 YAML 管道的多存储库支持将很快用于 azure devops 服务。
请检查功能:Azure DevOps Feature Timeline 2020 Q2中的“YAML 管道的多存储库支持”。此功能将于 2020 年 7 月底向所有人推出。
解决方法:
您可以尝试使用 Pipeline triggers。
步骤如下:
第一步:创建一个带有web应用仓库的管道,然后你可以设置触发分支。
第 2 步:在 Yaml 文件中添加管道触发器(UI Automation Repo)。
例如:
resources:
pipelines:
- pipeline: Name
source: Pipeline name
trigger:
branches:
- releases/*
- master
当您在网络应用程序存储库中进行更改时,将触发网络应用程序的管道。
在 运行 管道之后,将触发带有 UI 自动化回购的管道。
Can we store our test case files in the application repository and give the path of the test script?
当然。你可以的。
如果你想在管道中使用测试文件(UI Automation repo),你可以在管道中添加 repo resouces。
例如:
resources:
repositories:
- repository: MyAzureReposGitRepository
type: git
name: MyProject/WebapplicationRepo
...
steps:
- checkout: MyAzureReposGitRepository
注意:回购将检出到代理源文件夹。
希望对您有所帮助。