NUNIT Error - No suitable constructor was found

I m using NUNIT Framework and trying to do a simple check of connecting to an API object. API but I keep getting this error: OneTimeSetUp: No suitable constructor was found.

I used similar constructor with a different framework (selenium specflow) and no issues but not sure about NUNIT Any idea how to resolve this please?

   namespace DemoTest.Cases
    {

 [TestFixture(typeof(APIExample))]
    public class Test
    {
        
        public APIExample _apiExampleObject;

        public Test(APIExample apiExampleObject)
        {
            _apiExampleObject = apiExampleObject;
        }

  
        [Test]
        public async Task API_Test()
        {
         await _apiExampleObject.GetResponse();
         
        }
    }
}

Shouldnt it be

        [OneTimeSetUp]
        public Test(APIExample apiExampleObject)
        {
            _apiExampleObject = apiExampleObject;
        }

?

NUnit needs to know to call Test before running any tests…

1 Like

Thanks. It is close to your suggestion but managed to get it to work by creating a parameterless constructor and instantiate the object there. This seems to work now

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.