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

问题描述 投票:0回答:1

基于NUnit的example,在Appcenter github存储库中可用,我得到了以下构建后脚本:

#!/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测试结果:”,然后永远挂起。

[有人在Appcenter中成功配置xUnit测试吗?提供的脚本有什么问题?

xamarin continuous-integration xunit visual-studio-app-center
1个回答
0
投票

我现在也面临着同样的问题。问题在于,由于我的xunit单元测试项目针对.NET框架,因此Appcenter构建VM无法运行它。我将我的单元测试项目更新为.NET Core 2.0,它开始像魅力一样开始工作。

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

© www.soinside.com 2019 - 2024. All rights reserved.