Visual Studio 2008 Extension to test a function quickly? C#
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.
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:
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
.