Running Class fixtures in a Release Pipeline

35 views Asked by At

I've been doing some build validation testing for a project. I'm running two tests. The class running those tests has a class fixture that is configuring and running the set up and tear down before and after the tests are ran.

I'm using Visual studio to implement the BVTs and the test are running fine here locally. However, I deployed the repository with the BVTs to Azure Dev Ops release pipeline using the Visual Studio Test stage and its failing.

Has anyone else ran into this issue?

1

There are 1 answers

4
Bright Ran-MSFT On

Before running the Visual Studio Test task, you need to build the related projects within the solution at first. Then use the output DLL files to do the tests.

If you want to directly run the test project without an addition previous build step, you can check out the source code into the pipeline working directory, then use the .NET Core task to execute the 'dotnet test' command with the test project.

The 'dotnet test' will automatically build all the related projects before starting the tests.

For example, there are two projects within the same solution:

  • The class library project: MathCalc/MathCalc.csproj
  • The test project to test the class library: TestMathCalc/TestMathCalc.csproj

Using below task can directly execute the test project without adding a previous build step.

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: test
    projects: TestMathCalc/TestMathCalc.csproj
    arguments: '-c $(BuildConfiguration)'
    testRunTitle: 'TestMathCalc.TestOperators_$(Release.ReleaseId)'