Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio 2008 Extension to test a function quickly? C#

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?

Thanks...

Please say if the question is not clear enough?

like image 872
JL. Avatar asked Sep 18 '09 14:09

JL.


3 Answers

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.

like image 105
Ben M Avatar answered Sep 21 '22 23:09

Ben M


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

like image 41
Donut Avatar answered Sep 20 '22 23:09

Donut


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.

like image 45
Noldorin Avatar answered Sep 18 '22 23:09

Noldorin