Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何配置VS Appcenter为Xamarin/Droid运行xUnit测试_Xamarin_Continuous Integration_Xunit_Visual Studio App Center - Fatal编程技术网

如何配置VS Appcenter为Xamarin/Droid运行xUnit测试

如何配置VS Appcenter为Xamarin/Droid运行xUnit测试,xamarin,continuous-integration,xunit,visual-studio-app-center,Xamarin,Continuous Integration,Xunit,Visual Studio App Center,基于Appcenter github存储库中提供的for NUnit,我得到了以下构建后脚本: #!/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 -rege

基于Appcenter github存储库中提供的for NUnit,我得到了以下构建后脚本:

#!/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
我在本地测试了这个脚本,效果很好。 当Appcenter执行sctipt时,它会写入“XUnit tests result:”,然后永远挂起


是否有人在Appcenter中成功配置了xUnit测试?提供的脚本可能有什么问题?

我现在也面临同样的问题。问题是,由于我的xunit单元测试项目是针对.NET framework的,Appcenter build VM无法运行它。我将我的单元测试项目更新为.NETCore2.0,它开始工作起来很有魅力


我的观点是,单元测试运行应该是appcenter-pre-build.sh的一部分,因为在apk被签名和上传后知道单元测试失败是没有意义的。越早越好。

谢谢您的回答-关于预构建的有效点。我已经有了针对.NETCore2.2的测试项目。我的问题似乎不是运行测试,而是从trx文件收集结果。最后,我为运行单元测试配置了Azure管道。appcenter在这方面运气不佳。您是否也可以检查软件包的版本是否相同或更高。xunit-2.4.0、xunit.runner.visualstudio-2.4.0、Microsoft.NET.Test.SDK-15.9.0。如果没有,请将nugets更新到这些版本,然后重试。我能够运行xunit测试用例,结果将保存在Appcenter本身的trx文件中。