-1

While running unit tests as part of Azure CI pipeline (YAML)

  • task: DotNetCoreCLI@2 displayName: Run Test Processor inputs: command: 'test'

Test methods [DataTestMethod] are not executed. But [TestMethod] is working fine.

Anish
  • 103
  • 2
  • 5

1 Answers1

0

The following yaml works fine on the newest version of Azure Devops (cloud).

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: path/to/.csproj
    arguments: '--configuration $(BuildConfiguration)'

Make sure it also works fine on your local machine to avoid it being any issues with the code.

To answer your bonus question

" Well you can either add a test category and filter it on the category, or filter it on the test projects if you have multiple of them.

I would probably do it with test categories

[Category("MainTest")] 
[Test] 
  public void TestMethod1() 
  { 
    Assert.True(true); 
  } 

And then in your yaml you should be able to do something like

testFiltercriteria: 'TestCategory=MainTest' "

HitzSPB
  • 158
  • 10
  • How to build only a certain test classes under the test project? – Anish Jun 05 '20 at 23:16
  • You should only ask 1 question, and either search for the answer on your next, or post a new one if is not possible to find a already answered questions. Otherwise it will be confusing when people find this answer and have to find out what solved this issue. If it solved your issue you should pick the answer as the most correct one, by marking the ✅ and continue with your work :) However I added a little bonus answer into my answer that should solve your problem. – HitzSPB Jun 06 '20 at 08:08