How do I search for failed tests using MRQL

The possible results for tests are usually stored in a field called "test run result".

The actual result depends on the configuration for test execution, which is a project setting. Tests can fail for multiple reasons, e.g. because one or more test steps have failed or because they have been manually set to fail.

The search expression must catch all of these failures, e.g.

mrql:"test run result"~"error" or "test run result"="f"

will searches for failed tests for this configuration

The "test run result"~"error" finds the test results which are set to error because one or more test steps has failed: the actual value would be "af|error|failed", so a search "test run result"="af|error|failed" would return the same failed tests in above configuration. The actual, exact test results to search for these automatic tests is the values "1|2|3" or "code|render|human" variables of the line in automatic.

The manual test results, where an operator uses the drop down to overwrite the automatic overall result just store "4" meaning the "code", so in case of failed tests in the above configuration, an"test run result"=""f".

Look at this example video where we find failed, passed and in progress test results:

So in short to find the exact search expression for your configuration can be a bit tricky, let us know for which projects you want to run an mrql search and we can help you...