OTB, unit testing can be so simple

Source: Internet
Author: User

I have been using. netfor more than two years. Fortunately, 2010 and 2008 have been used in the project, and the tools are relatively new. I feel a little better than those who are still using 2003 and 2005. Haha.

However, VS2008 has a BTO function, which can be used to test library-like methods on a graphical interface. John can see it from this ebook today, I suddenly thought it was silly to use NUnit for unit testing in my previous work. It was a waste of time.

OTB (Object Test Platform) is an Object Test platform. as its name implies, OTB is used to Test an Object. When do we need this tool? I believe that many programmers, like me, prefer to write code and test a piece of code. However, in many cases, it is difficult to test code without a presentation layer. For example, a class library, in the past, I used unit testing tools such as NUnit to test the class library. The main idea is to assert that the returned result is consistent with your expectation, then report, but it feels a little troublesome to use. First, you must think about the test cases. Generally, there are at least three. Then you need to write the test code, this process is like copying a text.

OTB is easy to use. First, it is a graphical interface, which is easy to use. Second, you can immediately see the return value of the method without building a temporary presentation layer for display.

Next, we will briefly introduce how to use OTB.

1. compile your class

2. VS toolbar-> View-> other Windows-> Object Test history. the OTB window is displayed at the bottom of VS and the start is blank.

3. open the Class View, right-click the class you want to test and choose Create instance> OK, if there is no problem in constructing the class instance, a class box will appear in OTS, indicating that the instance is instantiated successfully. Otherwise, an error is displayed in the window and the exception type is displayed.

4. the Method of the test class can be right-clicked on the class you just instantiated in the OTB window, then click Invoke Method, select the Method you want to test, enter the parameter, if successful, A new square is displayed in the form to record your test.

5. If you want to test the Static Method of the class, you do not need to instantiate the class. Right-click the Class View and choose Invoke Static Method to obtain all Static methods of the class. The test process is the same.

 

OTS also has its drawbacks, that is, it cannot be tested in batches. If the class library contains dozens of methods, operations on the graphic interface will be quite uncomfortable, therefore, the traditional unit test method is more practical in this case. When you write some code and see all the unit test results report a green light, you are in a good mood.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.