问题描述
在我的单元测试运行的方法,有合同和LT;>,它失败与错误:
在调用执行程序时发生异常执行人:// mswptestadapter / V1':对象引用不设置到对象的实例。
==========运行测试完成:0运行(0:00:28.8388006)==========
下面是pxproj文件合同的设置。
< codeContractsEnableRuntimeChecking>假< / codeContractsEnableRuntimeChecking>
< codeContractsRuntimeOnlyPublicSurface>假< / codeContractsRuntimeOnlyPublicSurface>
< codeContractsRuntimeThrowOnFailure>真< / codeContractsRuntimeThrowOnFailure>
< codeContractsRuntimeCallSiteRequires>假< / codeContractsRuntimeCallSiteRequires>
< codeContractsRuntimeSkipQuantifiers>假< / codeContractsRuntimeSkipQuantifiers>
< codeContractsRun codeAnalysis>假< / codeContractsRun codeAnalysis>
< codeContractsNonNullObligations>真< / codeContractsNonNullObligations>
< codeContractsBoundsObligations>真< / codeContractsBoundsObligations>
< codeContractsArithmeticObligations>假< / codeContractsArithmeticObligations>
< codeContractsEnumObligations>假< / codeContractsEnumObligations>
< codeContractsRedundantAssumptions>假< / codeContractsRedundantAssumptions>
<$c$cContractsMissingPublicRequiresAsWarnings>True</$c$cContractsMissingPublicRequiresAsWarnings>
&LT; codeContractsInferRequires&GT;真&LT; / codeContractsInferRequires&GT;
&LT; codeContractsInferEnsures&GT;假&LT; / codeContractsInferEnsures&GT;
&LT; codeContractsInferObjectInvariants&GT;假&LT; / codeContractsInferObjectInvariants&GT;
&LT; codeContractsSuggestAssumptions&GT;假&LT; / codeContractsSuggestAssumptions&GT;
&LT; codeContractsSuggestRequires&GT;真&LT; / codeContractsSuggestRequires&GT;
&LT; codeContractsSuggestObjectInvariants&GT;假&LT; / codeContractsSuggestObjectInvariants&GT;
&LT; codeContractsRunInBackground&GT;真&LT; / codeContractsRunInBackground&GT;
&LT; codeContractsShowSquigglies&GT;真&LT; / codeContractsShowSquigglies&GT;
&LT; codeContractsUseBaseLine&GT;假&LT; / codeContractsUseBaseLine&GT;
&LT; codeContractsEmitXMLDocs&GT;假&LT; / codeContractsEmitXMLDocs&GT;
&LT; codeContractsCustomRewriterAssembly /&GT;
&LT; codeContractsCustomRewriterClass /&GT;
&LT; codeContractsLibPaths /&GT;
&LT; codeContractsExtraRewriteOptions /&GT;
&LT; codeContractsExtraAnalysisOptions /&GT;
&LT; codeContractsSQLServerOption /&GT;
&LT; codeContractsBaseLineFile /&GT;
&LT; codeContractsCacheAnalysisResults&GT;真&LT; / codeContractsCacheAnalysisResults&GT;
&LT; codeContractsFailBuildOnWarnings&GT;假&LT; / codeContractsFailBuildOnWarnings&GT;
&LT; codeContractsRuntimeCheckingLevel&GT;完整和LT; / codeContractsRuntimeCheckingLevel&GT;
&LT; codeContractsReferenceAssembly&GT;%28none%29&LT; / codeContractsReferenceAssembly&GT;
&LT; codeContractsAnalysisWarningLevel&GT; 0℃/ codeContractsAnalysisWarningLevel&GT;
我失踪了code合同的.Net和Visual Studio 2012的扩展:
code合同净 - <一个href="http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F1ec7db13-3363-46c9-851f-1ce455f66970%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNGLZoTI_GSQJfSfJP5JuSNvv8SlOw" rel="nofollow">http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F1ec7db13-3363-46c9-851f-1ce455f66970%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNGLZoTI_GSQJfSfJP5JuSNvv8SlOw
code合同编辑器扩展VS2012 - <一个href="http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F02de7066-b6ca-42b3-8b3c-2562c7fa024f%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNEHZ2ObOxX0KF5PK7DAme9C1zh6Kg" rel="nofollow">http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F02de7066-b6ca-42b3-8b3c-2562c7fa024f%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNEHZ2ObOxX0KF5PK7DAme9C1zh6Kg
When my unit test runs a method that has Contract.<>, it is failing with an error:
An exception occurred while invoking executor 'executor://mswptestadapter/v1': Object reference not set to an instance of an object.
========== Run test finished: 0 run (0:00:28.8388006) ==========
Here is contracts settings in pxproj file.
<CodeContractsEnableRuntimeChecking>False</CodeContractsEnableRuntimeChecking>
<CodeContractsRuntimeOnlyPublicSurface>False</CodeContractsRuntimeOnlyPublicSurface>
<CodeContractsRuntimeThrowOnFailure>True</CodeContractsRuntimeThrowOnFailure>
<CodeContractsRuntimeCallSiteRequires>False</CodeContractsRuntimeCallSiteRequires>
<CodeContractsRuntimeSkipQuantifiers>False</CodeContractsRuntimeSkipQuantifiers>
<CodeContractsRunCodeAnalysis>False</CodeContractsRunCodeAnalysis>
<CodeContractsNonNullObligations>True</CodeContractsNonNullObligations>
<CodeContractsBoundsObligations>True</CodeContractsBoundsObligations>
<CodeContractsArithmeticObligations>False</CodeContractsArithmeticObligations>
<CodeContractsEnumObligations>False</CodeContractsEnumObligations>
<CodeContractsRedundantAssumptions>False</CodeContractsRedundantAssumptions>
<CodeContractsMissingPublicRequiresAsWarnings>True</CodeContractsMissingPublicRequiresAsWarnings>
<CodeContractsInferRequires>True</CodeContractsInferRequires>
<CodeContractsInferEnsures>False</CodeContractsInferEnsures>
<CodeContractsInferObjectInvariants>False</CodeContractsInferObjectInvariants>
<CodeContractsSuggestAssumptions>False</CodeContractsSuggestAssumptions>
<CodeContractsSuggestRequires>True</CodeContractsSuggestRequires>
<CodeContractsSuggestObjectInvariants>False</CodeContractsSuggestObjectInvariants>
<CodeContractsRunInBackground>True</CodeContractsRunInBackground>
<CodeContractsShowSquigglies>True</CodeContractsShowSquigglies>
<CodeContractsUseBaseLine>False</CodeContractsUseBaseLine>
<CodeContractsEmitXMLDocs>False</CodeContractsEmitXMLDocs>
<CodeContractsCustomRewriterAssembly />
<CodeContractsCustomRewriterClass />
<CodeContractsLibPaths />
<CodeContractsExtraRewriteOptions />
<CodeContractsExtraAnalysisOptions />
<CodeContractsSQLServerOption />
<CodeContractsBaseLineFile />
<CodeContractsCacheAnalysisResults>True</CodeContractsCacheAnalysisResults>
<CodeContractsFailBuildOnWarnings>False</CodeContractsFailBuildOnWarnings>
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>0</CodeContractsAnalysisWarningLevel>
I was missing Code Contracts for .Net and Visual Studio 2012 extension:
Code Contracts for .Net - http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F1ec7db13-3363-46c9-851f-1ce455f66970%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNGLZoTI_GSQJfSfJP5JuSNvv8SlOw
Code Contracts Editor Extensions VS2012 - http://www.google.com/url?q=http%3A%2F%2Fvisualstudiogallery.msdn.microsoft.com%2F02de7066-b6ca-42b3-8b3c-2562c7fa024f%3FSRC%3DVSIDE&sa=D&sntz=1&usg=AFQjCNEHZ2ObOxX0KF5PK7DAme9C1zh6Kg
这篇关于code合同无法正常工作在Windows Phone 8的单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!