I now know that the unit test tools on vs are: 1. Use the test project to test 2. Use the nunit plug-in 3. Moq plug-in.
I don't know the reason. The unit test that comes with vs is not easy to implement. But after a long time, I finally finished nunit. Let's talk about it.
First of all, I have to emphasize a few points. The Unite tool download found in vs> Tools> Extension Manager is invalid. At least I am invalid. I don't know why, maybe it is a version issue?
In addition, download nunit from the website and install it. In this case, nunit is independent of vs. You need to import the generated DLL file.
However, after nunit is installed, the visual nunit icon will be displayed in View> other windows, but I cannot display it for debugging. Depressed
Finally, we found that you want to install a "href =" http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099 "> visual nunit 2010 installed effect as shown in
The worst thing is that the unit test that comes with vs is not easy.
------------------------------------------- The following content is a supplementary part -----------------------------------------------------
Now I understand something:
Moq is not a unit test tool (plug-in), but a class library or a DLL file. It is used to simulate data (moking ).
Its relationship with nunit: Moq is used to simulate data (usually objects), and nunit is used for specific tests. Of course, the unit test and nunit functions provided by vs are tied in parallel, and they can be chosen for uprising.
Use Moq to introduce the Moq. dll file. The use of Moq has no relationship with keywords such as [test]. These keywords are used in unit testing. In short, Moq has no direct relationship with unit testing. You can simulate a piece of data used in your project to view some results.
With nunit, you can create a class at will, and mark the class and method with [testfixture] and [test], and import the DLL file nunit. framework.
To use vs unit test, you must create a test project separately. The classes and methods are marked as [testclass] and [testmethod] respectively.
---------------- PS -------------------
The above is a lot of nonsense. It is super simple to use the unit test provided by. Create a new unit test project under the solution (this is an independent project ).
View code
[Testclass] public class testdemo {[testmethod] public void mytest () {// reference the object here and call the method. Right-click the current location and choose run unit test to run smoothly }}