Created
October 1, 2019 13:36
-
-
Save felipebaltazar/38c4ea4f6ecfafafd262a859ca7db59b to your computer and use it in GitHub Desktop.
NUnit tests on app center
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# | |
# For Xamarin, run all NUnit test projects that have "Test" in the name. | |
# The script will build, run and display the results in the build logs. | |
echo "" | |
echo "==============================================================================" | |
echo "Task : Unit Tests" | |
echo "Description : Run unit tests and print results." | |
echo "Version : 1.0.0" | |
echo "Author : Felipe baltazar" | |
echo "Help : [More Information](https://github.com/felipebaltazar)" | |
echo "==============================================================================" | |
echo "" | |
echo "Building NUnit test projects:" | |
find $APPCENTER_SOURCE_DIRECTORY -regex '.*Test.*\.csproj' -exec msbuild {} \; | |
echo | |
echo "Running NUnit tests:" | |
find $APPCENTER_SOURCE_DIRECTORY -regex '.*bin.*Tests.dll' -exec dotnet vstest /logger:"trx;LogFileName=TestResult.trx" {} + | |
echo | |
echo "NUnit tests result:" | |
pathOfTestResults=$(find $APPCENTER_SOURCE_DIRECTORY -name 'TestResult.trx') | |
cat $pathOfTestResults | |
echo | |
#look for a failing test | |
grep -q 'failed="0"' $pathOfTestResults | |
if [[ $? -eq 0 ]] | |
then | |
echo "" | |
echo "All tests passed!! ๐ช๐๐๐" | |
else | |
echo "" | |
echo "One or more test Failed!! ๐จ๐" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment