简体   繁体   中英

How can I run MongoDB server and visual studio unit tests in an Azure DevOps pipeline?

I have a set of Visual Studio unit test projects which uses mongodb for execution.

I want to run the tests using Azure DevOps pipeline, can anyone help me with the YAML snippet for the same? (I am new to Azure pipelines and docker)

In future it would help if you posted your current YAML pipeline for additional context or possible gotchas.

But here is a rough pipeline using a service container ;

resources:
  containers:
  - container: mongodb
    image: mongodb
    ports:
    - 27017:27017

services:
  mongodb: mongodb

steps:

#insert pre-test set-up steps here

- task: DotNetCoreCLI@2
  displayName: dotnet test
  inputs:
    command: test
    projects: **/*.Tests/*.csproj
    arguments: --configuration Release

Your integration tests should use a host value of 'mongodb:27017' in the connection string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM