简体   繁体   English

在 Azure DevOps Build Pipeline 中运行测试

[英]Run tests in Azure DevOps Build Pipeline

I would like to make a build pipeline in Azure DevOps including tests/code coverage.我想在 Azure DevOps 中创建一个构建管道,包括测试/代码覆盖率。

For that, I created a very basic Java project:为此,我创建了一个非常基本的 Java 项目:

package main:
    - main class
    - Calculator class
          - add method
package test:
    - CalculatorTest class
        - addTest method

It's very basic, just for me to understand how test in pipeline work.这是非常基础的,只是让我了解管道中的测试如何工作。 I don't use maven or things like that.我不使用 maven 或类似的东西。 For the tests, I'm using JUnit framework.对于测试,我使用的是 JUnit 框架。

In Azure DevOps pipeline, I imported my project from Github, and started to create the pipeline.在 Azure DevOps 管道中,我从 Github 导入了我的项目,并开始创建管道。 I start from the starter template, which contains:我从入门模板开始,其中包含:

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

steps:
- script: echo Hello, world!
  displayName: 'Run a one-line script'

- script: |
    echo Add other tasks to build, test, and deploy your project.
    echo See https://aka.ms/yaml
  displayName: 'Run a multi-line script'

My question is:我的问题是:

What do I have to do to run my tests automatically ?我必须做什么才能自动运行我的测试?

I've seen several examples on the Microsoft documentation but it was always for "complex" projects (like with maven etc.).我在 Microsoft 文档中看到了几个示例,但它总是用于“复杂”项目(如 maven 等)。 And ass I'm new with Azure DevOps and YAML file/syntax, I'm lost.屁股我是 Azure DevOps 和 YAML 文件/语法的新手,我迷路了。

I want to run my tests after each commit, and see the results (test + code coverage) in the pipeline summary, like it is described here : https://docs.microsoft.com/en-us/azure/devops/pipelines/test/review-continuous-test-results-after-build?view=azure-devops#view-test-results-in-build我想在每次提交后运行我的测试,并在管道摘要中查看结果(测试 + 代码覆盖率),就像这里描述的那样: https : //docs.microsoft.com/en-us/azure/devops/pipelines /test/review-continuous-test-results-after-build?view=azure-devops#view-test-results-in-build

Thanks a lot.非常感谢。

PS: For the moment I'm just focusing on tests but once it will be done I also would like to publish build artefacts. PS:目前我只专注于测试,但一旦完成,我也想发布构建工件。 I would like the confirmation of that:我想确认一下:

- task: PublishBuildArtifacts@1

Is that line correct ?那条线正确吗?

EDIT编辑

The line - task: PublishBuildArtifacts@1 seems to work correclty but I have the following warning:该行- task: PublishBuildArtifacts@1似乎正常工作,但我有以下警告:

Directory '/home/vsts/work/1/a' is empty. Nothing will be added to build artifact 'drop'.

What does it mean ?这是什么意思 ?

Finally I used the visual designer (like explained here: https://docs.microsoft.com/en-US/azure/iot-edge/how-to-ci-cd ) and I added the Maven task.最后,我使用了可视化设计器(如此处所述: https : //docs.microsoft.com/en-US/azure/iot-edge/how-to-ci-cd )并添加了 Maven 任务。

I upgraded my project to use Maven, which is well integrated in Azure Devops.我升级了我的项目以使用 Maven,它很好地集成在 Azure Devops 中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure DevOps 发布管道中运行 Java Selenium 测试 - Run Java Selenium tests in Azure DevOps release pipeline Azure DevOps Pipeline 中的 Maven 构建错误 - Maven build error in Azure DevOps Pipeline Azure DevOps Maven 构建管道 - 将构建 ID 添加到清单文件 - Azure DevOps Maven Build PIpeline - Add build id to the Manifest File Azure Devops 构建失败 - Failure in build on Azure Devops Azure Devops 管道构建失败未能执行目标工件信息不完整或无效“版本”缺失 - Azure Devops pipeline build failure Failed to execute goal The artifact information is incomplete or not valid 'version' is missing 如何在 Azure DevOps 管道中安装 Java? - How to install Java in an Azure DevOps pipeline? 适用于不同环境的 Azure JAVA 函数 + DevOps 管道 - Azure JAVA Functions + DevOps pipeline for different environment 在Azure DevOps管道生成上收到此错误“无法执行目标org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” - getting this error “Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile” on Azure DevOps pipeline build gradle build with subprojects, git feature branches and jenkins multibranch pipeline: 如何只在受影响的子项目上运行测试 - gradle build with subprojects, git feature branches and jenkins multibranch pipeline: how to only run tests on affected subprojects Azure DevOps Pipeline 上的错误“-source 6 中不支持菱形运算符” - Error on Azure DevOps Pipeline "diamond operator is not supported in -source 6"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM