views:

150

answers:

1

I had set up a bunch of NUnit unit tests using the Test connection string in my App.config file and everything was working fine.

Then all of a sudden all my tests stopped working and threw the same exception:

System.ApplicationException : Connection string 'ApplicationServices' does not exist

Yet here are the contents of my App.config file with the missing connection string clearly visible:

<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <connectionStrings>
            <add name="ApplicationServices" 
                connectionString="Test" 
                providerName="System.Data.SqlClient"/>
        </connectionStrings>
    </configuration>

Has anyone else come across this and if so how did you get around it?

+3  A: 

I'm not sure if this is exactly the same problem, but I ran into what sounds like a very similar issue recently. My SubSonic 3 nunit tests had been working just fine and dandy for some time, until I created one grand-unified AllTests.nunit project file that I used to pull a bunch of separate test projects together into one. When I ran AllTests.nunit, my tests in the SubSonic project began to fail with exactly the same error you're describing.

The solution: alongside AllTests.nunit, I created AllTests.config, the contents of which are as follows:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="Some Name" connectionString="Some Connection String"/>
  </connectionStrings>
</configuration>

Hope that helps.

Skinniest Man
@Skinniest Man I simply removed the xxx.nunit file and the tests ran again - thanks
Ian Oxley