Tutorial :Migrating from NUnit to Team System error in Enterprise library configuration



Question:

I get this error from my migration of NUnit to Team System when running some of the tests in Visual Studio:

Test method XXX.XXX.Data.Tests.Path.Method> threw exception:  System.Configuration.ConfigurationException: Invalid section name. The section 'dataConfiguration' does not exist in the requested configuration file 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\vstesthost.exe.Config' or the file 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config'. Make sure that the 'enterpriseLibrary.configurationSections' configuration section exists in one of the files and that the section 'dataConfiguration' is defined..

  1. We are assuming it is the enterprise library, what is needed in the
    "configuration section" for my tests to work?
  2. Where does one usually find the configuration file in team system?
  3. Also why is the application still working and the tests not?


Solution:1

It sounds like it can't find the app.config/web.config file.

With MSTest, it doesn't test in the usual "output" directory. As a consequence, the "copy to output directory" (etc) flags do nothing. You need to tell it which files to deploy to the test folder; there are two ways:

  • edit the testrunconfig file and add the files to the deployment list
  • add the [DeploymentItem] attribute to your test, telling it which files are needed

I don't really like either approach - in fact, I tend to use TestDriven.NET to run the tests, which does it the way you expect it to behave.

Of course, TestDriven.NET would also run your NUnit tests in the IDE including code-coverage etc - which would then beg the question: why change your existing tests if they can work in the IDE? And the obvious answer is "we've paid for MSTest, and TestDriven.NET isn't free"...


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »