TheChaseMan's Frenetic SoapBox

Always looking for better ways to do things...

Object Test Bench

I ran into this today when using the “extract interface” refactoring ability in Visual Studio 2005…Object Test Bench? What is that about? Well, it’s pretty slick. Let’s say I make a class called SeanMath and develop the the best, most original function called Add to add a couple of integers together.

public class SeanMath {
    public static int Add(int a, int b) {
        return a + b;
    }
}

If I want to test my really cool Add method (see Figure 1)

  • I go to Class View
  • Right-click SeanMath
  • Point to “Invoke Static Method”
  • Point to my Add method

Then it prompts me to enter in my parameters as shown in Figure 2…After I click OK, my results are displayed as shown in Figure 3. Of course, you can do this with non-static methods as well. There is one extra step to do that, and that is to use the “Create Instance” command first as illustrated in Figure 4. Next, I assign the instance an object name as shown in Figure 5. After I name my object, it appears in the Object Test Bench (on the bottom of the IDE by default) as shown in Figure 6.

Next, I right click on my object, and invoke the Add method as shown in Figure 7. From this point, it works just like the “Invoke Static Method” functionality I described above.

Pretty slick, huh? :-)


Digg!

posted on Wednesday, October 20, 2004 5:02 PM

Feedback

# re: Object Test Bench 2/9/2005 2:14 AM Partho

Refer to the link for more information...

# re: Object Test Bench 2/21/2005 9:56 PM Eric

One should note that it works only for projects set as the StartUp project.