Take the 2-minute tour ×

I have a function buried deep inside an assembly, eventually this function will get called by my program, but I really don't want to have to debug it all the way to get to this function.

Is it not possible to get a module / addon for visual studio 2008, where I can just select the function I want to run, provide the parameters, and it will automatically either return the value or best case to actually fire up the debugger, so that breakpoints are met?


Please say if the question is not clear enough?

share|improve this question
add comment

6 Answers

up vote 9 down vote accepted

Sometimes the object test bench is a bit clumsy; you can also use the much simpler Immediate Window: Debug -> Windows -> Immediate.

Then you can type:

MyNamespace.MyClass.MyStaticMethod() [enter]

If there's a breakpoint in the method, the debugger will start and break at that position.

If you need to call an instance method:

new MyNamespace.MyClass().InstanceMethod() [enter]

You can also create variables and assign them return values--then call methods on those variables.

The immediate window can also be used during a debug session. When a thread is in the break state, you can execute methods using information (such as variables in scope) from the current debug context. Very useful!

The only downside is that every identifier entered in the immediate window has to be fully-qualified with its namespace, so you end up typing quite a bit.

share|improve this answer
Another problem is that httpContext is no longer available, but overall its a good idea. –  JL. Sep 18 '09 at 15:35
add comment

You might want to try the Object Test Bench.

From MSDN:

Object Test Bench (OTB) is designed for simple object-level testing. Use OTB to create instances of your project's objects, invoke methods, and evaluate the results. This way, you shorten the task of coding, debugging and re-coding. Visual C#, Visual Basic and Visual J# support testing methods in OTB.

In the View menu:
alt text

share|improve this answer
I love how adding a screenshot for even the most trivial things always gains more votes... –  Noldorin Sep 18 '09 at 15:20
Haha... we posted the same link for the same thing at almost the same time. What can I say, I'm a sucker for competition :) Although, I've upvoted you to keep things even. –  Donut Sep 18 '09 at 15:23
add comment

I think you're looking for the Object Test Bench. This feature was designed precisely for testing classes and methods on the fly, as you write the code.

MSDN states that it desirable to use for the following tasks:

  • Teaching object-oriented programming concepts without going into language syntax.
  • Providing a lightweight testing tool designed for academic and hobbyist programmers to use on small and simple projects.
  • Shortening the write-debug-rewrite loop.
  • Testing simple classes and their methods.
  • Discovering the behavior of a library API quickly.

You can access it through View > Other Windows > Object Test Bench.

share|improve this answer
add comment

Create unit tests with NUnit, and use TestDriven.NET for integration in Visual Studio

share|improve this answer
+1 TestDriven is excellent. –  user7116 Sep 18 '09 at 15:13
add comment

Run an Nunit test with a test runner

This assumes of course you can mock/stub out any dependencies on this code. Could you provide the code in question?

share|improve this answer
add comment

If you only have VS2008 Express, which doesn't include the Testing functionality, you could use NUnit and write a unit test for your method, and use a test runner such as Testdriven.NET

share|improve this answer
VS 2008 Pro does have test functionality. It's the standard/express editions that don't. –  Pete OHanlon Sep 18 '09 at 15:01
Installing now... will post feedback... –  JL. Sep 18 '09 at 15:01
sorry I meant standard. Will update... –  Mitch Wheat Sep 18 '09 at 15:10
add comment

Your Answer


