简体   繁体   中英

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.

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.

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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