简体   繁体   English

Visual Studio:是否可以将参数值从调试流导出到单元测试数据输入?

[英]Visual Studio: Can I export parameter values from debug flow to unit test data inputs?

For instance, I've got a complex function Foo(ObjectA a, ObjectB b) where a and b take a substantial amount of time to compose (because they're coming from a non-local server that cannot be localized for testing purposes), I'd love to be able to snatch these guys up in Visual Studio debug and say, here, make me a unit test or something where I can quickly load these values up again statically. 例如,我有一个复杂的函数Foo(ObjectA a, ObjectB b) ,其中ab需要花费大量时间来编写(因为它们来自非本地服务器,该本地服务器无法进行测试) ,我很希望能够在Visual Studio调试中抢这些家伙,然后说,在这里,让我进行单元测试,或者可以快速地再次静态地加载这些值的东西。

Thanks! 谢谢!

--edit-- we're definitely assuming that the a and b are serializable or something, where they'll be stored off in some persistent data storage file, and retrieved when the unit test starts up. --edit--我们绝对假设a和b是可序列化的或类似的东西,它们将被存储在一些持久数据存储文件中,并在单元测试启动时被检索。

Just a workaround I could provide: 我可以提供一种解决方法:

You could export the object value during debugging with certain extension tool like Object Exporter, and then read the file with database or others in your unit test(data driven unit test). 您可以在调试过程中使用某些扩展工具(例如Object Exporter)导出对象值,然后在单元测试(数据驱动的单元测试)中与数据库或其他文件一起读取文件。

https://marketplace.visualstudio.com/items?itemName=OmarElabd.ObjectExporter https://marketplace.visualstudio.com/items?itemName=OmarElabd.ObjectExporter

But whether the saved value was refreshed before the unit test calls the saving file, it would be a testing issue. 但是,是否在单元测试调用保存文件之前刷新保存的值,这将是一个测试问题。 Hope it could provide a path for you. 希望它可以为您提供一条道路。

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

相关问题 Visual Studio /反射/序列化:是否可以从调试会话中导出值以将其用于单元测试? - Visual Studio / Reflection / Serialization: Can I export values from a debug session to use them for unit testing? 如何在Visual Studio 2017 15.6.0中调试单元测试 - How can I debug unit test in Visual Studio 2017 15.6.0 如何将值列表作为参数传递给Visual Studio Web性能测试或加载测试插件? - How can I pass a list of values as a parameter to a Visual Studio web performance test or load test plugin? 如何从Visual Studio 2012调试引用的dll - How can I debug a referenced dll from Visual Studio 2012 为什么在Visual Studio 2012中运行测试时看不到调试输出? - Why I can't see the debug output when I run a test in Visual Studio 2012? Visual Studio调试单一测试 - Visual Studio Debug Single Test 单元测试,NUnit或Visual studio? - Unit test, NUnit or Visual studio? 如何在 Visual Studio 2010 中并行化数据驱动的单元测试? - How to parallelize a Data-Driven unit test in Visual Studio 2010? 如何从Unit测试方法访问数据文件? - How can I access a data file from a Unit test method? 当我运行单元测试时,Visual Studio崩溃了 - When I run a unit test visual studio crashed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM