Search code examples
c#seleniummstestspecflow

Trying to run Specflow tests but error returned - Unit Test Provider already specified


I've been looking at similar questions on different websites in the hope I could find an answer for it but I've not come across something which has worked for me.

I have a Visual Studio 2019 solution (.Net Framework) which contains Specflow related tests. I can see all my tests in the Test Explorer but when I try to run any of them, I am returned with the error 'Unit test provider already specified'. My test runner was initially Specflow.SpecRun but I have since removed all references to this and am now using Specflow.MsTest - this is to allow me to associate my test cases to one in Azure DevOps. Only after making this change, I am getting these errors.

I have searched across my solution and there are no longer any references to SpecRun; there are no build errors either. The 'Enable SpecflowSingleFileGenerator' setting is set to False, I do have an app.config file but do not have a specflow.json file - I read that that is only needed for .NET Core projects.

Has anyone else come across the above or have any ideas to resolving it as I am a bit stuck.


Solution

  • I was having this problem when I moved from nUnit to MsTest. I want to add few more steps to comments mentioned

    1. Check your feature.cs files and make sure it has onlyMicrosoft.VisualStudio.TestTools.UnitTesting attributes and not nUnit or specrun
    2. Check whether you are using any local.testsettings file in visual studio
    3. Remove nUnit from tools and extensions if you are not using it.
    4. Restart VS, clear temp folder, clean and rebuild