使用Moq包模拟接口不适用于Azure DevOps CI Build Pipeline VsTask。 Xamarin Nunit测试:VsTask失败,并显示错误 错误:进程“ C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Enterprise \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest.console.exe”失败,退出代码为1
错误失败 错误信息: System.IO.FileNotFoundException:无法加载文件或程序集'Mono.Android,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = 84e04ff9cfb79065'。系统找不到指定的文件。
池:
vmImage:“ vs2017-win2016”
需要: -MSBuild Xamarin.Android JDK vstest任务:VSTest @ 2
输入:
testSelector:“ testAssemblies”
testAssemblyVer2:| \ UserModuleNUnitTest.dll ! * TestAdapter.dll ! \ obj。
searchFolder:
'$(build.binaries目录)/ $(BuildConfiguration) codeCoverageEnabled:否 任务:PublishTestResults @ 2
displayName:“发布API测试结果”
输入:
testResultsFormat:VSTest
testResultsFiles:“ ** / *。trx”
所有测试用例应在本地Visual Studio 2019上执行时成功执行。 在构建管道的日志中显示以下错误。
Failed Register_Api_Call
Error Message:
System.IO.FileNotFoundException : Could not load file or assembly 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. The system cannot find the file specified.
Stack Trace:
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at Castle.DynamicProxy.Generators.MethodSignatureComparer.GetHashCode(MethodInfo obj)
at System.Linq.Set`1.InternalGetHashCode(TElement value)
at System.Linq.Set`1.Add(TElement value)
at System.Linq.Set`1.UnionWith(IEnumerable`1 other)
at System.Linq.Enumerable.DistinctIterator`1.FillSet()
at System.Linq.Enumerable.DistinctIterator`1.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at Castle.DynamicProxy.Generators.MethodFinder.GetAllInstanceMethods(Type type, BindingFlags flags)
at Castle.DynamicProxy.Contributors.MembersCollector.CollectMethods(IProxyGenerationHook hook)
at Castle.DynamicProxy.Contributors.MembersCollector.CollectMembersToProxy(IProxyGenerationHook hook)
at Castle.DynamicProxy.Contributors.InterfaceProxyWithoutTargetContributor.CollectElementsToProxyInternal(IProxyGenerationHook hook)+MoveNext()
at Castle.DynamicProxy.Contributors.CompositeTypeContributor.CollectElementsToProxy(IProxyGenerationHook hook, MetaType model)
at Castle.DynamicProxy.Generators.InterfaceProxyWithoutTargetGenerator.GenerateType(String typeName, Type proxyTargetType, Type[] interfaces, INamingScope namingScope)
at Castle.DynamicProxy.Generators.InterfaceProxyWithTargetGenerator.<>c__DisplayClass6_0.<GenerateCode>b__0(String n, INamingScope s)
at Castle.Core.Internal.SynchronizedDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Castle.DynamicProxy.Generators.BaseProxyGenerator.ObtainProxyType(CacheKey cacheKey, Func`3 factory)
at Castle.DynamicProxy.ProxyGenerator.CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, IInterceptor[] interceptors)
at Moq.Mock`1.InitializeInstance()
at Moq.Mock`1.OnGetObject()
at Moq.Mock`1.get_Object()
at Tests.Registration.Setup() in D:\a\1\s\UserModuleNUnitTest\Registration.cs:line 38
Results File: D:\a\1\s\TestResults\VssAdministrator_fv-az45_2019-08-24_11_45_24.trx
答案 0 :(得分:0)
@Snehal Jadhav这可能是因为您的应用程序找不到汇编文件- Mono.Android 。 验证以下内容后,您可以重新运行测试吗?
您可以通过在Windows计算机上查看其详细信息来检查当前dll文件的版本。