It should be simple, but I am not able to make it.
Setup
Everything is nice.
I am trying to execute all my unit tests before committing.
If any unit test failed I will prevent the commit.
I am doing this in the pre-commit
git hook.
And I was able to make it with this code (inside the pre-commit
hook)
if ! dotnet test --nologo --verbosity q > buildoutput.txt
then
echo "Test failed"
exit 1
fi
exit 0
everything is fine and good, I have a very small problem
I do not want the [xUnit.net] logs from showing its log in the Git panel
I just want to show a simple message that 'Test failed'
How can I prevent the xUnit package from showing those messages?
it appears the output is coming from stderr
in your command you're only piping stdout to the file (>
):
if ! dotnet test --nologo --verbosity q > buildoutput.txt
you can additionally pipe stderr by using >&
(or > 2>&1
for slightly more compatibility):
if ! dotnet test --nologo --verbosity q >& buildoutput.txt