Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Nunit没有在任何测试方法中运行_C#_Nunit - Fatal编程技术网

C# Nunit没有在任何测试方法中运行

C# Nunit没有在任何测试方法中运行,c#,nunit,C#,Nunit,我在班级图书馆里有两个班 namespace ClassLibrary3 { public class Class1 { public string title; public string author; public Class1(string title, string author) { this.title = title; this.author = author; } } } 另一类 using System

我在班级图书馆里有两个班

namespace ClassLibrary3
{
public class Class1
{
    public string title;
    public string author;
    public Class1(string title, string author)
    {
        this.title = title;
        this.author = author;
    }
}
}
另一类

using System;
using System.Collections;
using System.Linq;
using System.Text;

namespace ClassLibrary3
{ 二级 { 私人哈希表书籍

    public Class2()
    {
        books = new Hashtable();
    }

    public void addBook(Class1 book)
    {
        books.Add(book.title, book);
    }

    public Class1 getBook(String title, String author)
    {
        return (Class1)books[title];
    }

    public void removeBook(string title)
    {
        if (books[title] != null)
            books.Remove(title);
    }


}
}   
我的测试是

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Collections;
namespace ClassLibrary3
{
[TestFixture]
class TEST
{
    [Test]
    public void getbooktest()
    {
    Class1 c1 = new Class1("story", "James");
    Class2 c2 = new Class2();

   Assert.AreEqual("story", c2.getBook("story", "James"));

    }
}
}
基本上,问题是Nunit不测试它。它找到dll。加载测试类。但不使用测试方法。
请注意………

除非您将测试类标记为公共,否则无法查看您的测试类,请将其更改为

[TestFixture]
public class TEST
{
   ...

侧注,考虑比测试更好的名称;-)

nUnbe不能看到您的测试类,除非您将其标记为“公共”,将其改为

[TestFixture]
public class TEST
{
   ...

旁注,考虑比Nobe更好的名称;-n/p>测试是由nUnbe看到的。但是问题是它不访问GoBooGoT()。NeUnt是测试。但问题是它没有访问GoBooGooTestTo()。谢谢。我得到了。问题是,在一次愚蠢的尝试中,我给出了类“test”的名称。。这是一个关键字。谢谢。我知道了。问题是-在一次愚蠢的尝试中,我给出了类“TEST”的名称。这是一个关键字。