简体   繁体   中英

Resharper test runner can't find connection string on Run All

I have a Visual Studio project structure something like this:

Base (no connection string)
Data (connection string to Sql Server, references Base)
Logic (connection string to Sql Server, references Base & Data)
Base.Test (no connection string, references Base)
Logic.Test (connection string to Sql Server, references Base & Data & Base.Test)

When I use Resharper to run all the unit tests on each of the test projects separately, they pass. But when I run all unit tests across all projects, the Base tests pass first and then the Logic tests fail because it can't find the connection string.

When I debug, I can see it does actually have one connection string to SqlExpress, which I gather is being generated by Entity Framework, which seems to come from another project higher up the chain?

How can I get the Logic.Test project to use its own connection string from app.config on Run All?

I believed I had a similar problem a long time ago, and I seem to remember I had to change some ReSharper settings ( ReSharper -> Tools -> Options | Tools | Unit testing )

I'm checking my options right now, and I have Shadow-copy un-ticked and Separate AppDomain ticked.

You should give it a try.

EDIT :

it seems just ticking the Separate AppDomain checkbox is sufficient, regardless of the Shadow-copy setting.

The alternative solution was to simply duplicate the app.config onto the Base.Test project. Not ideal as conceptually that project didn't relate to database work at all, but the solution did work in both the dev environments and TeamCity test runner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM