Run Java Selenium tests in Azure DevOps release pipeline

纵饮孤独 提交于 2020-05-17 07:02:31

问题


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.

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.

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.

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

  • Copy the whole project to the artifacts directory of the release during build (copy files task).
  • Add a Maven task to the release pipeline
  • Trigger the Selenium tests in pom.xml

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

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.

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


回答1:


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, 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, Publish artifacts to release pipeline

3, In the release pipeline, add the task to execute the tests just like the way you do in build pipeline



来源:https://stackoverflow.com/questions/57807346/run-java-selenium-tests-in-azure-devops-release-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!