Open sudhirbits opened 10 months ago
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 result
if echo "$NEWMAN_RESULT" | grep -q "failures="; then
echo "Tests failed."
exit 1 # Exit with a non-zero status to indicate failure
else
echo "Tests passed."
fi
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").
hope it helps :)
Is there an option to make the newman execution fail if it did not run any tests?