NUnit没有发现任何测试

时间:2017-07-16 15:19:03

标签: c# nunit visual-studio-2017

我正试图让NUnit第一次工作。

我试过了:

  1. 将默认处理器架构更改为X64
  2. 安装所有最新,稳定版本的NUnit,NUnit Console和NUnit3TestAdapter。
  3. 我尝试使用NS2TestAdapter,但没有任何区别
  4. 这是输出:

    using System;
    
    
    namespace bankAccount
    {
    public class Account
    {
        private int balance;
    
        public Account(int initialBalance)
        {
            balance = initialBalance;
        }
    
        public void credit(int amount)
        {
            balance += amount;
        }
    
        public void debit(int amount)
        {
            balance -= amount;
        }
    
        public int getBalance()
        {
            return balance;
        }
    }
    }
    

    要测试的课程:

      using System;
      using System;
      using System.Collections.Generic;
      using System.Text;
      using bankAccount;
      using NUnit.Framework;
    
      namespace accountTest
      {
          [TestFixture]
          public class AccountTest
          {
        //private Account account;
    
        [Test]
        public void initialBalance()
        {
            Account account = new Account(100);
            Assert.AreEqual(100, account.getBalance());
        }
    
        [Test]
        public void credit()
        {
            Account account = new Account(100);
            account.credit(20);
            Assert.AreEqual(130, account.getBalance());
        }
    
        [Test]
        public void debitOk()
        {
            Account account = new Account(100);
            account.debit(20);
            Assert.AreEqual(80, account.getBalance());
        }
    }
    }
    

    然后是测试类:

    {{1}}

0 个答案:

没有答案