You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey @sudhirbits,
Newman doesn't have a built-in option to fail the execution explicitly if no tests are run.
However, you can achieve this by incorporating some scripting or checking mechanisms in your workflow.
So, after Newman execution we can use a script to check the number of executed tests from the report. If zero tests were run, set a non-zero exit code for the script, indicating failure.
Something like this:
# Run Newman and save the result in a variable
NEWMAN_RESULT=$(newman run your_collection.json -e your_environment.json)# Check if there are any test failures in the Newman resultifecho"$NEWMAN_RESULT"| grep -q "failures=";thenecho"Tests failed."exit 1 # Exit with a non-zero status to indicate failureelseecho"Tests passed."fi
Another option could be:
While using a CI/CD tool, configure it to fail the build based on the Newman exit code or specific keywords in the output (e.g., "0 tests executed").
Is there an option to make the newman execution fail if it did not run any tests?
The text was updated successfully, but these errors were encountered: