仿Nunit的【TEST】属性测试一段程序
做一个WEB服务项目时,经常要调试一段函数是否执行正确。经自己研究Nunit,自己编写了一个小型的测试工具:
一:添加一个custom attribute named "TestAttribute" the code is:
    [AttributeUsage(AttributeTargets.All,AllowMultiple=false)]
    public class TestAttribute :System.Attribute
    {
        public TestAttribute()
        { 
        }
    }
二:创建一个Console程序:
 Code
Code
三:然后在你想测试的方法前面加一个属性[Test()]
这样就可以测试了!
例如:
        [Test()]
        public void xx(string aa,string bb)
        {
            Console.WriteLine("xx method");
            Console.WriteLine(aa);
            Console.WriteLine(bb);
        }
第一次写文章,写得很差。呵呵! 
 
                     
                    
                 
                    
                

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号