为什么方法 DateTimeParse.TryParse(String, DateTimeFormatInfo, DateTimeStyles, DateTime&) 未经检测?
我一直在尝试让一些 PEX 示例正常工作,但是使用 DateTime.TryParse/DateTime.Parse 的任何内容都会产生令人失望的结果。 Pex 没有提出任何有趣的参数,如果我用一个可达到的含义来包装它,它只是说 1 个错过的目标。
我认为这一定是因为我收到有关 DateTimeParse.TryParse 未经检测的消息,但为什么它首先未经检测?如果“Microsoft Pex 的参数化测试模式”文档没有做任何有趣的事情,为什么它使用 DateTime 作为示例?
I've been trying to get some of the PEX samples working, but anything with DateTime.TryParse/DateTime.Parse produces dissapointing results. Pex does not come up with any interesting parameters, and if I wrap this with a reachable implication, it simply says 1 Missed Goal.
I think this must be because of the message I'm recieving about DateTimeParse.TryParse being uninstrumented, but why is it uninstrumented in the first place? Why does the document "Parameterized Test Patterns for Microsoft Pex" use DateTime as an example, if it does nothing interesting?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Uninstrumented 意味着 Pex 还没有探索过代码,也不知道它的路径,因此不能确保它会探索代码中的所有路径,因为它不知道如何探索
DateTime.TryParse
,以便生成输出,然后将其输入到代码路径。我希望你能遵循这一点。因此,如果您允许 Pex 检测
DateTime
类,它应该能够计算出代码中的路径并生成一些有用的探索。请查看使用 Microsoft Pex 进行参数化单元测试练习 4,希望它能比您引用的文档更好地解释它。 Pex 只会检测您告诉它的对象,因为这可能是一项昂贵的操作(并且最终可能会产生深度图)。在 Pex 探索的结果中,Pex 应该在信息栏中为您提供一条有关需要检测的类型的消息。
Uninstrumented means that Pex hasn't explored the code and doesn't know the paths for it, so can't ensure that it will explore all the paths in your code, because it doesn't know how to explore the paths in
DateTime.TryParse
, in order to generate the outputs that would then be inputs to your code paths. I hope you can follow that.Therefore, if you allow Pex to instrument the
DateTime
class, it should be able to work out the paths in your code and generate some useful explorations. Take a look at Parameterized Unit Testing with Microsoft Pex Exercise 4, which hopefully will explain it a bit better than the document you've referenced. Pex will only instrument objects you tell it to, as this is a potentially expensive operation (and could end up with a deep graph).In the result of the Pex Explorations, Pex should give you a message in the information bar about the types that need instrumentation.