在Azure DevOps发布管道中运行Java Selenium测试 [英] Run Java Selenium tests in Azure DevOps release pipeline

查看:217
本文介绍了在Azure DevOps发布管道中运行Java Selenium测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为AzureDevops CI/CD管道中的Java项目做POC.我创建了一个具有Selenium测试(TestNG)的Maven项目,该项目针对与我的项目无关的演示网站运行.我想在构建管道中运行单元测试,并在发布管道中运行UI Selenium测试.

I'm doing a POC for a Java project in an AzureDevops CI/CD pipeline. I created a Maven project that has Selenium tests (TestNG) that run against a demo website which is independent of my project. I want to run unit tests in the build pipeline and UI Selenium tests in the release pipeline.

Visual Studio test任务似乎是我需要的构建块.我认为您可以区分单元测试和UI测试使用测试文件"字段进行测试,例如** \ unit * Test.dll,** \ ui * Test.不幸的是,该任务对于Java项目不可用/不兼容.

The Visual Studio test task seems to be the building block that I need. I think you can differentiate between unit tests & UI tests using the 'Test files' field like **\unit*Test.dll, **\ui*Test. Unfortunately, this task is not available/compatible for Java projects.

我能够在构建过程中使用Maven任务和Surefire插件运行Selenium测试,但是请记住,我只想在构建过程中运行单元测试.

I was able to run the Selenium tests with the Maven task and Surefire plugin during build but remember, I only want to run unit tests during build.

实际上,我可以通过以下一种变通方法在发布管道中运行Selenium测试:

I actually was able to run the Selenium tests in the release pipeline via a workaround which was:

  • 在构建过程中将整个项目复制到发行版的工件目录(复制文件任务).
  • 将Maven任务添加到发布管道
  • 在pom.xml中触发Selenium测试

通常,您只会将工件复制到工件目录中,因此我认为这样做是一个巨大的漏洞.

Normally, you would only copy artifacts to the artifact directory so I think doing that is a huge hack.

另一个问题是Maven将在构建和发布期间构建项目,这很浪费.为了回避浪费,一些精明的Maven配置可能会有所帮助.我曾考虑过在发布期间跳过编译并解决依赖关系,但我不知道在DevOps生态系统中的哪里可以找到Maven依赖关系.

Another problem is that Maven will build the project during build and release which is wasteful. To dial back the waste, some savvy Maven configuration might help. I was thinking about skipping compilation and resolve dependencies during release, but I don't know where to find the Maven dependencies in the DevOps ecosystem.

我是否缺少某些东西,或者AzureDevops可能不能很好地支持Java?

Am I missing something or is AzureDevops maybe not supporting Java all that well?

推荐答案

您可以尝试像在构建管道中一样在发布管道中添加测试任务. 并在构建管道中添加复制任务,以将测试代码和文件复制到构建工件,并将其发布以发布管道.

You can try just adding a test task in your release pipeline just as in the build pipeline. And add a copy task in the build pipeline to copy the test codes and files to the build artifacts and publish it to release pipeline.

以下步骤仅供参考(在经典视图中).帮助它可能会有一些希望.

Below steps is just for reference(in classic view). Help it can be of some hope.

1,在构建管道中添加copy file任务,以将所有测试文件和所有从属设置文件复制到工件中的测试文件夹中.

1, Add copy file task in the build pipeline to copy the all test files and all the dependent setting files to the test folder in artifacts.

2,发布工件以发布管道

3,在发布管道中,添加任务以执行测试,就像在构建管道中一样

这篇关于在Azure DevOps发布管道中运行Java Selenium测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆