简体   繁体   English

PexObserve仅记录255个字符

[英]PexObserve only records 255 characters

I am using Pex from the command line to find input values for test case generation. 我从命令行使用Pex查找测试用例生成的输入值。 I use PexObserve to record certain values during execution. 我使用PexObserve在执行期间记录某些值。 One of the values that I want to record is an XML-String. 我要记录的值之一是XML字符串。

However, when parsing the XML I receive "malformed XML" exceptions, since Pex only writes the first 255 characters into the log. 但是,在解析XML时,我会收到“格式错误的XML”异常,因为Pex仅将前255个字符写入日志。

Is there a way to record the full XML string? 有没有办法记录完整的XML字符串? or does PexObserve have a different type that will let me record longer texts? 还是PexObserve有其他类型可以让我记录更长的文本?

Leaving this here, in case somebody at any point has the same issue. 如果有人在任何时候都遇到相同的问题,就把它留在这里。 I've found a solution that helped me. 我找到了对我有帮助的解决方案。

Unfortunately the 255 character limit is set internally in static readonly fields. 不幸的是,255个字符的限制是在内部static readonly字段中设置的。 Therefore I needed to use reflection. 因此,我需要使用反射。 My solution works by including the following line in the PUT: 我的解决方案通过在PUT中包含以下行来工作:

typeof(Microsoft.Pex.Framework.PexObserve.ValueWriterManager).GetField("MaxWrittenElements").SetValue(null, 1000);

Replace the 1000 with any value you like. 用您喜欢的任何值替换1000

BUT: remember that this is a quick-fix solution, that might not work for you. 但是:请记住,这是一个快速修复的解决方案,可能对您不起作用。 It may have unwanted side-effects. 它可能会有不良的副作用。 You're also changing the number of List elements that are written, and perhaps other things. 您还将更改写入的List元素的数量,也许还有其他事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM