构建运行良好,但在添加使用经典编辑或我的解决方案的构建管道时看不到单元测试结果。
并且代码覆盖率也是空白的。我的解决方案中有两个项目和测试项目。单元测试任务返回结果如下:
A total of 14 test files matched the specified pattern.
No test is available in d:\a\1\s\src.net...
Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: d:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx
Attachments:
d:\a\_temp\TestResults\d301a26b-d99f-4b4e-bbe8-c95e588ee1c5\VssAdministrator_fv-az686 2019-12-26 06_10_20.coverage
Vstest.console.exe exited with code 0.
**************** Completed test execution *********************
Test results files: d:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx
No Result Found to Publish 'd:\a\_temp\TestResults\VssAdministrator_fv-az686_2019-12-26_06_10_28.trx'.
Created test run: 1006840
Publishing test results: 0
Publishing test results to test run '1006840'. …Run Code Online (Sandbox Code Playgroud) 我的管道中有一个 .netcode 测试命令和一个发布代码覆盖率结果任务。
配置如下:
steps:
- task: DotNetCoreCLI@2
displayName: 'Test Public API Project '
inputs:
command: test
projects: '**/DWP.CDA.API.Test.csproj'
arguments: '--output publish_output --configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:Threshold=99 /p:ThresholdStat=total /p:CoverletOutput=$(Build.SourcesDirectory)\TestResults\Coverage\ --collect "Code coverage"'
steps:
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/TestResults/Coverage/*cobertura.xml'
reportDirectory: '($(Build.SourcesDirectory)/Src/TestResults/Coverage'
Run Code Online (Sandbox Code Playgroud)
但是好像发布结果没有生效,会显示这样的消息
[warning]No code coverage results were found to publish.
Run Code Online (Sandbox Code Playgroud) 我正在使用函数应用程序来获取密钥保管库证书,但出现如下异常:
系统无法
在 System.Security.Cryptography.CryptographyException.ThrowCryptographyException(Int32 hr)
处找到指定的文件 System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[] rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
在System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte [] rawData,对象密码,X509KeyStorageFlags keyStorageFlags)
在System.Security.Cryptography.X509Certificates.X509Certificate2 ..ctor(Byte [] rawData)
在DWP.CDA。 FunctionApp.Utils.CertificateHelper.GetKeyVaultCertificate(字符串 keyvaultName,字符串名称)
在 DWP.CDA.FunctionApp.ProcessRequest.Run(JObject eventGridEvent,TraceWriter 日志)
它在我的本地视觉工作室中运行良好,因为我使用自己的帐户来获得 azure 服务身份验证。我授予对我的帐户的完全访问权限,并在密钥库访问策略中授予对函数应用程序的访问权限
这是我的代码如何获取证书:
internal static X509Certificate2 GetKeyVaultCertificate(string keyvaultName, string name)
{
var serviceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(serviceTokenProvider.KeyVaultTokenCallback));
// Getting the certificate
var secret = keyVaultClient.GetSecretAsync("https://" + keyvaultName + ".vault.azure.net/", name);
// Returning the certificate
return new X509Certificate2(Convert.FromBase64String(secret.Result.Value));
}
Run Code Online (Sandbox Code Playgroud)