Visual Studio Basic Tools tutorial for unit test--llorch (ii)

Source: Internet
Author: User


A generic example illustrates:
  • This series of blogs discusses only the basics of the tool and does not discuss any language.
    •  Don't even discuss shortcut keys:-)
    • You can complete this tutorial with the mouse
  • The IDE default refers to Visual Studio Community Edition. At the end of this series of articles, you can skillfully use it to write programs.
  • The default layout state after Visual Studio startup is called the main window, and the project name displayed in the title bar of the main window is not necessary.
  • Several symbols describing menu actions are defined on the basis of daily spoken language and Windows Explorer: [], {},/, >>, =, (,).
  • check that a setting item is represented by:
    • [Window name]/{menu name}/{submenu name}/{Set item Item name}= Set value of item
  • For example, the default Debug configuration:
    • [Main Window]/{solution Configuration Manager}=debug
  • When checking multiple settings items, write each one in the same way as a single set item
  • When you check that a setting item has multiple values , parentheses are used to separate them with internal commas, such as:
    • [Solution Explorer]/{project name}/{reference}= (system,system.core,system.data,system.xml)
  • To perform a left-click sequence is to replace the last check with "/", such as exiting the IDE:
    • [main window]/{file}/{exit}/
  • The connection symbol for the right-click menu is >>, such as refreshing the Windows desktop:
    • [Desktop]>>{Refresh}/
  • The representation of a setting item in a pop-up window is similar to
  • The representation of the set item in the MDI child window is similar to the above, noting that in Visual Studio, the name of the MDI child window is in its upper-left corner or may be automatically adsorbed around the main window
  • title bar and status bar as the promotion of the menu, applicable to the above presentation method
  • Defect description
    • Welcome feedback, mailto:[email protected]
    • The preferred language for the author is C #
    • The author is a soft dog
    • The author's IDE does not have a Chinese language pack, so some nouns are not translated correctly:-(
    • Due to the lack of clarification of the relevant certificate issues, copyright reserved
    • Series of articles did not propose or solve new problems, the purpose is only science




Body




First, testing


Test-first represents at least two good practices: one is to focus on the programming process in the follow-up work, and the second deeper reason is that the interface is already stable. The dialectical relationship between interfaces and implementations is that "dirty" code always begins with an unstable programming interface and implementation. The interface and the implementation are stable certainly not programming, but the product. It is possible to improve the stability of the interface and to achieve the unstable code, while the code of the interface instability is basically difficult to advance the work. In summary, you should not start writing code in the case of an unstable interface.



The biggest difference between source code and code fragment is that the source code can remain stable for a period of time because the source code is fully tested. The general example can only explain the principle, as a snippet of code, and not as source code.



Test-first does not mean that a test project is created. Instead, you should create Project project 1 before you create Project Project 1Test. The logical order is this: first determine the type of the project, followed by the interface of the project, then write the contents of the test project according to the interface, and finally enter the "code-Test" cycle, until the code can pass the test. This is another "project X" work to begin with.





Second, Unit testing


Unit testing is the simplest and most necessary test. Visual Studio has integrated good unit testing practices, let's get started:-)



[main window]/{file}/{new}/{project}/



[New Project]/{Unit test Project}/



[New Project]/solution = Add to current solution



[New Project]/ok/



In this way, we have a new test project in our solution. You can find a reference to a test project very simple. By adding a reference to the project you want to test at the reference, you can begin writing the test function.



The way to run the test project is to:



[main window]/{test}/{run}/{all tests}/



This will pop up the test explorer and tell the user about the problem that occurred during the test function execution. It is noteworthy that, from beginning to end, it is not recommended to write the main () method separately for each test, because the console application corresponding to the main () method is the frontend of a system. Of course, it's also good to write a dedicated console application for all the testing.





Third, the difference between testing and debugging


The most intuitive difference is that the debugging is to check whether the state at the breakpoint meets the expectations, and the test is to see if the overall behavior is as expected. The purpose of debugging is to ensure the correct implementation, focusing on the internal implementation of the interface, usually without the use of specialized external code. The goal of the test is to focus on the external behavior of the interface, with special external code. Some tests also need to be done with an external test set (which can be understood as a TXT file).





The code quality of the test


Another lovely benefit of testing is that the requirements of the test code are not as demanding as the formal code:-). You can usually borrow some textbooks or official sample code.





Five, the allocation of energy in programming


The wisdom of testing lies in concentration. Testing from the process, it is a short period of time to determine the test method, and then a large period of time to write the actual work of the code. It avoids the embarrassment of developers writing business code and validating code at the same time. Therefore, the advantage of testing is that the developer will focus on the implementation.



Not only that, the test ensures that the entire development work is done around the interface and facilitates reuse and upgrades.





Summarize


Testing done with Visual Studio can only be a beginning for users to understand software engineering, but "focus on programming over time" rather than writing a lot of hard-to-control main methods is worth keeping.



Visual Studio Basic Tools tutorial for unit test--llorch (ii)


Related Article

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.