代码契约无法在Windows Phone 8的单元测试工作(Code Contracts not w

2019-09-29 13:17发布

当我的单元测试运行具有合同的方法<>,它与一个错误而失败:

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) ==========

这里是pxproj文件合同设置。

    <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>

Answer 1:

我失踪了的.Net和Visual Studio 2012的扩展代码契约:

代码契约对于.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

代码契约编辑器扩展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 Contracts not working in Windows Phone 8 unit test