问题标签 [pex]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
696 浏览

visual-studio-2010 - 如何从项目中移除 Moles?(摩尔 0.94.51023.0 / VS2010 SP1)

问题

我不仅不能使用 Moles看到这篇文章我也无法摆脱它们(就像我的后院一样)。我确定我遗漏了一些[对我来说]不明显的东西。我知道我不是唯一有这个问题的人。

症状

删除 moles 配置文件(我认为在项目目录中,不记得名称)并删除对我重建的 mscorlib moles/behaviors 的引用并添加回引用后。我还删除了 MolesAssemblies 目录,尽管下面的链接说该错误已修复。

杂项链接

我找到了删除 MolesAssemblies 目录的旧参考(我尝试过),但很久以前就修复了。

我还发现了这个关于在家去除痣的详细建议,但它也不起作用;)

0 投票
1 回答
1343 浏览

visual-studio-2010 - 在特定机器上运行 Pex 时未注册接口(0x80040155)

Pex 0.94.0.0 发布 Visual Studio 10.0.40219.1 错误报告

如何重现:

  1. 打开一个类库项目
  2. 创建一个空方法
  3. 右键单击-> 运行 Pex

我在另一台机器上运行没有问题(在 Office 中,VS2010 Utimate)

但是我在家用电脑上遇到了这个异常(VS2010 Professional)


异常详细信息:System.InvalidCastException:无法将“System.__ComObject”类型的 COM 对象转换为接口类型“EnvDTE.DTE”。此操作失败,因为 IID 为“{04A72314-32E9-48E2-9B87-A63603454F3E}”的接口的 COM 组件上的 QueryInterface 调用因以下错误而失败:接口未注册。(HRESULT 的异常:0x80040155)在 Microsoft.Pex.VsPackage.VsServiceProviderHelper.GetService[T](IServiceProvider serviceProvider) 在 Microsoft.Pex.VsPackage.Helpers.ProjectHelper.SaveAllFiles(IServiceProvider serviceProvider) 在 Microsoft.Pex.VsPackage.Actions.ActionComponent .SaveAll() 在 Microsoft.Pex.VsPackage.Actions.ExplorationActionBase.InternalExecute() 在 Microsoft.Pex.VsPackage.Actions.ActionComponent.Execute(对象目标)


Microsoft.Pex.VsPackage.Controls.ErrorReport.<>c_DisplayClass4.b 的 Microsoft.Pex.VsPackage.Controls.ErrorReport.CreateReport(Exception ex) 的当前堆栈跟踪_3() 在 System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo 方法,对象目标,Object[] 参数,SignatureStruct& sig,MethodAttributes methodAttributes,RuntimeType typeOwner) 在 System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo 方法,对象目标,Object[] 参数,签名 sig , MethodAttributes methodAttributes, RuntimeType typeOwner) 在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfoculture, Boolean skipVisibilityChecks) 在 System.Delegate.DynamicInvokeImpl(Object[] args) 在 Microsoft .Pex.VsPackage.Helpers.UIThreadInvoker.SafeMethodInvoker.Invoke() 在 System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo 方法,对象目标,对象 [] 参数,SignatureStruct& sig,System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo 方法,对象目标,Object[] 参数,签名 sig,MethodAttributes methodAttributes,RuntimeType typeOwner)中的 MethodAttributes methodAttributes,RuntimeType typeOwner)在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binding , Object[] 参数, CultureInfo 文化, Boolean skipVisibilityChecks) 在 System.Delegate.DynamicInvokeImpl(Object[] args) 在 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) 在 System.Threading.ExecutionContext.runTryCode(Object userData) 在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode 代码, CleanupCode backoutCode, Object userData) 在系统。Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback , 对象状态) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms .Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object状态)在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control .ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control .ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)上 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)的 .OnMessage(Message& m)RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)上 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)的 .OnMessage(Message& m)IntPtr lparam)IntPtr lparam)对象状态)在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Windows.Forms.Control .InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System .Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)对象状态)在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) 在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 在 System.Windows.Forms.Control .InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System .Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control 的 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 的 ContextCallback 回调,对象状态,布尔 ignoreSyncCtx)。 InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control 的 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 的 ContextCallback 回调,对象状态,布尔 ignoreSyncCtx)。 InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,Int32 msg,IntPtr wparam,IntPtr lparam)InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System。 Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)InvokeMarshaledCallback(ThreadMethodEntry tme) 在 System.Windows.Forms.Control.InvokeMarshaledCallbacks() 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System。 Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)IntPtr wparam, IntPtr lparam)IntPtr wparam, IntPtr lparam)


相关环境变量:COR_ENABLE_PROFILER= COR_PROFILER= PROCESSOR_ARCHITECTURE=x86


机器数据:处理器计数 = 4

0 投票
1 回答
355 浏览

moles - 将 Moles 与 MsTest 一起使用时,痣会“冲突”

在使用 Moles 和 MsTest 时,我发现了一种可以解释(但令人沮丧)的行为。

想象一下以下情况:

  • “测试 DLL A”在 mscorlib 上使用 Moles
  • “测试 DLL B”在 mscorlib 上使用 Moles

为了缩短编译时间,在这两种情况下,我们都在编辑 .moles 文件,以便询问单个类的痣的生成。

当我们这样做时,我们的项目将编译得非常好。

但是当我们运行解决方案的测试时,MsTest 过程将是:

  • 复制“Out”文件夹中的所有 DLL
  • 在“Out”文件夹中运行测试

因此,复制到“Out”文件夹将尝试复制 mscorlib.Moles.dll 的两个版本(一个是类型 1,一个是类型 2),当然,第二个会覆盖第一个。

所以我对“Test DLL A”的测试将失败,因为我的鼹鼠组装不正确。

当然有两个简单的解决方法:

  • 在每个 .moles 文件中包含所有需要的类型(在所有项目中)
  • 要么不使用类型过滤

你也遇到过这个“问题”吗?还有其他解决方案吗?

非常感谢 !

Pierre-Emmanuel DotNetHub 用户组负责人

0 投票
0 回答
154 浏览

unit-testing - pex 参数化单元测试中的值生成

我正在使用 Pex 构建单元测试。我的问题不是所有代码分支都在测试,Pex 不断生成参数值,这些参数值在相同的条件下失败,这使得该条件之后的所有代码都无法运行。

我的方法是这样的:

我想知道是否可以告诉 Pex 通过该测试,以便可以访问所有代码。如果这是不可能的,是否可以让 Pex 为其中一项测试采用函数参数的默认值(我认为如果它不存在,这将是一个很好的功能)。

谢谢

0 投票
2 回答
642 浏览

unit-testing - 如何在公共类痣中转移“非公共”方法

我有一个使用本地私有方法从数据库获取数据的公共方法。

private string SomeMethod(string) { ... Doing some operations ... string data = GetDBData(string); Doing some operations ... }

我想使用 moles 转移/隔离私有方法 GetDBData(string),这样我的测试就不需要数据库。

显然,我的问题是:怎么做?谢谢乌利亚

编辑
附加信息:

我尝试将方法访问器更改为公共和内部受保护的,在这两种情况下我现在都可以将方法视为痣。但是在运行测试时,仍在使用原始方法,而不是我在 PexMethod 中实现的弯路。

0 投票
2 回答
348 浏览

pex - Running Pex with .NET 3.5 projects

I'm currently trying to use Pex and Moles with a SharePoint 2010 solution that's written in .NET 3.5. When adding a test project (by using Pex -> Create parameterized tests) everything seems to work OK. However, when I try to compile I end up with a massive list of errors (missing namespaces and such) and warnings regarding referenced assemblies not being able to be resolved (such as System.Web which under .NET 4 is no single DLL anymore).

This is due to the projects under test is .NET 3.5 and the Pex test project is .NET 4.0 as far as I understand it, but is it possible to make this combination work at all?

0 投票
1 回答
125 浏览

code-contracts - Pex 不满足代码合同

我正在尝试编写一个 pex 测试,我注意到它总是提供一个错误值作为我想要的参数之一。我的测试看起来像这样(简化:有/还有更多参数,但没有什么不同):

我想测试一个场景,让 pex 进行探索,确保这value是真的。我做了另一个看起来像这样的测试:

但是当我让 Pex 探索它时,它仍然会吐出错误的结果,value并且它生成的测试“通过”。如果我在要求后面加上一行,Contract.Assert(!value);它将创建另一个测试并通过 truevalue以使断言失败。

问题是,为什么 Pex 不满足代码合同?

0 投票
2 回答
378 浏览

visual-studio-2010 - 'RUN PEX' 不会出现在右键单击上

我在 Windows XP 机器上运行 VS2010 Pro。我已经下载并安装了 PEX & Moles。一切都很顺利。当我打开 C# 项目并将光标放在类方法上并右键单击时,我看不到“运行 pex”或“pex”选项,根据(安装)文档应该是这种情况。

据我所知,我已经按照书本完成了所有工作,但没有快乐。似乎我在某个地方忘记了什么,但是什么?谁能帮帮我?

0 投票
1 回答
482 浏览

visual-studio-2010 - Visual Studio 2010 Ultimate 中的 Pex 和 F#

我一直在尝试在 F# 项目中使用 Pex,但我遇到了几个问题,希望能得到一些帮助:

  1. Visual Studio Pex 插件工作了半个小时,而不是用于复杂的项目探索。

  2. 之后,每次我从 Visual Studio 2010 中运行 Pex 探索时,都会收到一条!warning! [metadata] no explorations found after applying all filters; did you forget a [PexClass] or [PexMethod] attribute?错误消息。如果我在进行探索时复制并粘贴 Visual Studio 运行的命令并删除一些属性(如 sourceFilter ...)并从命令控制台运行它,那么我会得到一些生成的测试。知道为什么 Visual Studio 会生成无效命令吗?

  3. 一段时间后,Microsoft.Pex.Framework.dll 要么从 .Net 引用列表中消失,我必须使用其文件路径手动引用它,或者我什至无法再引用它,我必须卸载/重新安装 Pex。( A reference to C:\Program Files (x86)\Microsoft Moles\PublicAssemblie\Microsoft.Pex.Framework.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.)

当我处理 C# 项目时,不会发生所有这些问题。

学术版出现问题 1 2 3。

使用可用于 MSDN 订阅者的版本,我从来没有在 Visual Studio (Visual Studio 2010 Ultimate NO SP1) 中使用它。但是它可以在命令提示符下工作。这个版本我没有遇到问题3。

有没有人设法让 Pex 在 Visual Studio 中与 F# 一起工作?如果是,你能告诉我你是怎么做到的吗?您使用哪些版本(VS 和 Pex)?

0 投票
0 回答
149 浏览

moles - Moles 0.94安装找不到pex.powertool.x64.msi

我正在尝试安装最新的 Moles/Pex 0.94,但安装无法卸载以前的版本,因为它找不到 pex.powertool.x64.msi。我在这里的多台计算机上搜索了此文件,但似乎无法在任何地方找到它。这个文件在某处可用,还是有办法手动删除 pex/moles?