NUnit学习笔记

 [TestFixture]
    public class Class1
    {
        [TestFixtureSetUp]  //程序开始运行时,只执行一次,如打开数据库等操作。
        public void OpenConnection()
        {  
            Console.WriteLine("OpenConnection");
        }
        [TestFixtureTearDown] //程序停止运行时,只执行一次,如关闭数据库等操作。
        public void CloseConnection()
        {        
            Console.WriteLine("CloseConnection");
        }
        [SetUp]//每个测试用例启动时执行一次
        public void InitializeOperands()
        {        
            Console.WriteLine("InitializeOperands");
        }
        [TearDown] //每个测试用例结束时执行一次
        public void DeleteDatabaseObjects()
        {       
            Console.WriteLine("DeleteDatabaseObjects");
        }
        [Test] //需要测试的方法
        public void TransferFunds()
        {       
            Console.WriteLine("TransferFunds");
            Assert.AreEqual(250, 250);    
        }
        [Test]
        public void TransferFunds1()
        {
            Console.WriteLine("TransferFunds1");
            Assert.AreEqual(250, 250);
        }
        [Test]

        [Ignore("Multiplication is ignored")] //暂时不想测试这用例的时候可以这样做。
        public void MultiplyTwoNumbers()
        {     
            int product =2;
            Assert.AreEqual(2, product);

        }
    }

你可能感兴趣的:(学习笔记)