Skip to content

Instantly share code, notes, and snippets.

@15mgm15
Created January 25, 2019 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 15mgm15/ae4801b65bfda9a2bc08fef47252e636 to your computer and use it in GitHub Desktop.
Save 15mgm15/ae4801b65bfda9a2bc08fef47252e636 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# For Xamarin, run all NUnit test projects that have "Unit" in the name.
# The script will build, run and display the results in the build logs.
echo "Found NUnit test projects:"
find $APPCENTER_SOURCE_DIRECTORY -regex '.*Unit.*\.csproj' -exec echo {} \;
echo
echo "Building NUnit test projects:"
find $APPCENTER_SOURCE_DIRECTORY -regex '.*Unit.*\.csproj' -exec msbuild {} \;
echo
echo "Compiled projects to run NUnit tests:"
find $APPCENTER_SOURCE_DIRECTORY -regex '.*bin.*Unit.*\.dll' -exec echo {} \;
echo
echo "Running NUnit tests:"
find $APPCENTER_SOURCE_DIRECTORY -regex '.*bin.*Unit.*\.dll' -exec nunit3-console {} +
echo
echo "NUnit tests result:"
pathOfTestResults=$(find $APPCENTER_SOURCE_DIRECTORY -name 'TestResult.xml')
cat $pathOfTestResults
echo
#look for a failing test
grep -q 'result="Failed"' $pathOfTestResults
if [[ $? -eq 0 ]]
then
echo "------------ A test Failed!!! --------------"
exit 1
else
echo "------------ All tests passed :D --------------"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment