问题标签 [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.
c# - 如何让 Pex 使用 DateTime.Now 或 File.Exists 处理函数
我是 Pex 的新手,我看不到如何将它与机器特定的例程一起使用,例如 DateTime.Now 和 File.Exists()。
我有一个功能可以显示带有时区偏移的截止日期时间。
我有一个由 Pex Explorer 生成的 Pex 参数化测试
然而,这会生成一个特定于机器的测试——当机器处于非 GMT 时区时它会失败。
在这种情况下我能做什么?我可以告诉它跳过引用 DateTime.Now 或 File.Exists() 等函数的探索函数吗?或者我可以告诉它总是以某种方式使用特定的时区吗?
pex - Pex 在工厂方法中报告 PexAssumeFailedException
每个人!我是单元测试的初学者。我现在正在使用 Visual Studio 2010 和 Pex 测试一个项目,我遇到了以下问题。
当我运行 Pex 探索时,Pex 告诉我“无法创建 Root.Reports.Type1FontData 的实例”,并且 Pex 报告的详细信息是:
--- 异常详情
Microsoft.Pex.Framework.Exceptions.PexAssumeFailedException:段索引 0 处的 FontDataTest.sGetTextLine(FontData, String, Double, Int32&, TextSplitMode) 需要 Type1FontData 类型的对象(某些对象#0);ExSig#1 的扩展序列
1.我只是想测试一个抽象类的方法'FontData.sGetTextLine()',代码如下:
}
2. 类'Type1FontData'是基于抽象类'FontData'的具体类,Type1FontData的代码为:
}
3.然后Pex帮我生成一个PUT类方法'FontDataTest.sGetTextLine()':
}
4. 运行 Pex Exploration 后,Pex 显示一条消息“猜猜如何创建 Root.Reports.Type1FontData”。然后我点击“编辑工厂”和Pex创建一个Type1FontDataFactory类,代码是
}
5. 当我再次运行 Pex Exploration 时,我得到了 PexAssumeFailedException“无法创建 Root.Reports.Type1FontData 的实例”。
6. Type1FontDataFactory.Create()的动态代码覆盖率汇总显示用户代码或测试只覆盖了以下代码:
我的问题是如何处理这个问题,请帮助我!
谢谢你们 !
moles - 生成痣存根
我是 Pex 和 Moles 的新手,我想利用参数化单元测试。我正在使用构造函数注入,我想为我的参数创建一个 moles 存根。
我读过的文档说 Moles 将为我的 SIUserRepository 存储库生成一个存根类型。但我不知道如何生成存根。谁能提供一个例子。谢谢
pex - 使用 Pex 测试私有方法
我想在我的项目中使用 Pex 和 Moles。我想使用 Pex 测试 Private 方法。
有人用 Pex 测试私有方法吗?
如果我们不能直接测试,是否有任何解决方法来测试私有方法?
moles - 使用 Pex 和 Moles 的 Moled 数据集
我想测试下面的方法。我正在返回数据集并检查表集合。
我在下面使用 Pex 编写了单元测试。
现在我因为 DataTablecollection 错误而得到 MoledNotImplemented。我怎样才能摩尔数据集表集合?
unit-testing - How to tell PEX to use the mock object when the concrete object is a dependency, and then auto-generate test cases?
I am writing client-side components in a provided framework, and need to be able to unit test my components. The components are written using MVP (Model-View-Presenter) pattern, I want to use PEX to automatically generate unit tests for my presenters.
The following is the code of a presenter.
The problem I am having is that the object SystemClient
is provided by the framework, and I cannot use a factory class to create an instance of SystemClient
. Therefore when I run PEX to automatically generate unit tests, I have to tell PEX to ignore SystemClient
, the result of this is that the method DeleteRecord
is not fully covered as the line Client.SystemName != "Ruby"
is not tested.
Since I have the mock object MSystemClient
(created using moles), I am wondering if somewhere in the configuration I could tell PEX to use MSystemClient
, and let PEX to automatically generate test cases to fully cover this method.
moles - 如何在 pex 中将 GUID 作为 Pex 参数传递
如何使用 PexArgument 属性将 GUID 作为 Pex 参数传递?
pex - 如何在 Pex 中定义一组输入参数?
假设我有 100 个字段的 MyClass。
如果我使用 MyClass 的对象作为输入参数,Pex 会简单地阻塞尝试生成所有可能的组合(即使在简单的测试中,我也会遇到 1000 条路径)
[PexMethod] void MytestMethod(MyClass 参数){...}
如何告诉 Pex 只使用一组预定义的 MyClass 对象,而不是让它变得聪明并生成所有可能的组合来测试?
换句话说,我想在上面的代码中手动指定参数的可能状态列表并告诉 Pex 使用它
干杯
visual-studio - Moles v0.94 导致测试忽略配置文件
我使用 Moles v0.91 至少一年了,每天编写和执行数百个测试。升级到 v0.94 后,在 Moles 主机下运行的测试不再能够访问配置文件。这些测试在几天前运行良好。这些测试中的每一个的错误消息都清楚地表明它们无法访问配置,例如无法找到连接字符串。(是的,我知道好的单元测试不应该访问数据库。请不要专注于此)。
在同一个项目中,访问配置但不在 Moles 主机下运行的测试运行良好。
有关如何解决此问题的任何建议?在具有当前服务包的 Visual Studio 2008 和 2010 中以及在 .Net 3.5 和 .Net 4.0 下都发生。
更多详细信息:这是一个测试项目,其 app.config 已在同一项目中正确读取,用于不运行 Moles 主机的测试。使用企业库进行数据库和日志记录,两者都无法读取配置文件。