How to perform Nunit testing for a class inherting from a base class with parameterised constructor

我只是一个虾纸丫 提交于 2019-12-11 08:12:35

问题


namespace TestBI
{
 [TestFixture]
 class ClassChild:ClassParent
 {
    public ClassChild(DataRow row, string name): base(row, detail) { }
    [Test]
    public void Test()
    {
        DataRow dr = new DataRow();
        dr[0] = 1;
        dr[1] = "ram"  
        ClassChild ch = new ClassChild(dr,"student");

        :
        :
        :
        Assert.AreEqual(string1,string2);
     }

 }
}

When I run the test,i get an error as "TestBI.ChildClass.Test suitable constructor was found"

How do i need to pass parameters here to child class?


回答1:


Provide a zero argument constructor for your test class. It is fine if it calls a multiple argument constructor of the superclass, as long as it provides it with proper arguments.



来源:https://stackoverflow.com/questions/14603570/how-to-perform-nunit-testing-for-a-class-inherting-from-a-base-class-with-parame

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!