Based on example for NUnit, available in Appcenter github repository I got following post-build script:
#!/usr/bin/env bash
echo "Found Unit test projects"
find $APPCENTER_SOURCE_DIRECTORY -regex '*.Tests*\.csproj' -exec echo {} \;
echo
echo "Run Unit test projects"
find $APPCENTER_SOURCE_DIRECTORY -regex '*.Tests*\.csproj' | xargs dotnet test --logger "trx;LogFileName=testresult.trx";
#find file with results
echo "XUnit tests result:"
pathOfTestResults=$(find $APPCENTER_SOURCE_DIRECTORY -name 'testresult.trx')
echo
grep ' \[FAIL\]' $pathOfTestResults
failures=$(grep -o ' \[FAIL\]' $pathOfTestResults | wc -l)
if [[ $failures -eq 0 ]]
then
echo "Unit Tests passed"
else
echo "Unit Tests failed"
exit 1
fi
I tested script locally, it works fine. When sctipt executed by Appcenter, it writes "XUnit tests result:" and then hangs forever.
Did anyone succeeded with configuring xUnit tests in Appcenter? What could be wrong in provided script?