Debugging with OzCode: Create Data for Regression Tests

A good testing strategy may reduce your bugs tremendously. However, some bugs may still slip through and can only be found on your production environment. Today we look at a great feature of OzCode to isolate problematic data to use it in regression tests.

Let’s imagine you got a bug report, verified that the bug is real and now try to understand what is going on with your debugger attached to your system. You walked through all the method calls and figured out that a certain set of data isn’t processed correctly. To make this bug really annoying, this data comes from a source outside your control and it may change without further notice. Would it not be great to capture this data as it comes into your application? OzCode has a feature to do exactly that: Export.

All you need to do is to hover your mouse over the data you are interested in, wait till the OzCode menu pops up and select the magic wand to open the Export context menu:

You now get the export dialog that lets you view the data in C# code, as XML or JSON:

The default selection is to go 3 levels deep. As you can see in the screenshot above, that may not be enough to cover the data you are interested in. You can increase the depth on the right side. But be aware, the deeper you go the longer it takes to collect all the data.

When you have found a depth that covers your data, you can copy the data to your clipboard. This representation of production data can now be copied to your unit test. I suggest you copy that data to a separate method, that does not only keep your unit test small but you can reuse this data for other tests:

 

Conclusion

The export feature looks small but is very powerful. You aren’t limited to use it with production data but that’s where it is especially useful.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.