question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding a succeeding failure unit-test to a custom task fail Azure DevOps pipeline

See original GitHub issue

Environment

azure-pipelines-task-lib version: 2.9.3

Issue Description

I’m trying to build a very simple task that compute a valid version number based upon the current date/time.

I’m following the instructions on the Add a build or release task page and am trying to run unit-tests from an Azure DevOps pipeline.

Obviously, because there is failure test, I’m getting the failed output of the task in the failure test, like so:

image

However, because this is a custom DevOps task, it includes the #vso[task.issue type=error;] pattern as part of the failing test output. That pattern fails the Azure DevOps build:

Actual behaviour

image

Is there a way to prevent the task from emitting output during unit-testing. I probably could do it by supplying a custom input and change the code of my tasks but I wanted to know if there was a solution you had in mind.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mcafarocommented, Jan 14, 2020

I discovered my issue. You need to make sure you call mocha with the path to the suite.js. If you just cd in to the test directory and call mocha, it will spit out all of the ##vso lines.

@springcomp , you appear to be correctly calling mocha with the path to the suite.js, but you have an assertion error.

0reactions
springcompcommented, Apr 13, 2021

Going back to this issue now, I can confirm this is still not solved. Would be great to have official guidance for running failure unit tests in Azure DevOps.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In Azure DevOps, how do I prevent failing unit tests from failing ...
1 Answer 1 · Hmm, I don't see a visual editor for my pipeline, only YAML, and when I add continueOnError: true to...
Read more >
HOW TO FIX A FAILED TEST IN AZURE PIPELINE ... - YouTube
3,345 views • Jan 15, 2020 • AZURE DEVOPS. HOW TO FIX A FAILED TEST IN AZURE PIPELINE WITH AZURE DEVOPS ...
Read more >
Add a build or release task in an extension - Azure DevOps
The failure test validates that when the tool gets bad or incomplete input, it fails in the expected way with helpful output. First,...
Read more >
Unit test fails in Azure DevOps but passes locally
Then when you build a definition, using private agent, set task "VsTest" - "Other console option" to generate diagnostic trace logs where you...
Read more >
Staged execution of tests in Azure DevOps Pipelines
Each of the test tasks can be configured to not fail the executing pipeline. This is a standard feature that's found on every...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found