Unit Testing a Web Application Project with NUnit 2.4.6

My web application project works just fine, but I'm trying to start unit testing with NUnit. I have the Test and TestFixture properly set-up, but when I actually run a test against the project's DLL in my bin, the test case fails with the message that it cannot load the App_GlobalAssemblies. (The Trace tab says that App_GlobalResources is not a strong name.)

App_GlobalResources is a regular folder for Web Application Projects. It contains my Constants.resx file. The expression in my code that triggers the failure is: Resources.Constants.KeyValueName (where KeyValueName is the name of one of the key-value pairs in my resx file).

NUnit correctly makes its way to Constants.designer.cs, to try to call Assembly.Load(). Here's the rest of the stack trace. (The top line is ultimately where the failure happens.)

at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)

Any ideas on integrating NUnit for a project that uses App_GlobalResources? I *really* want to be able to perform unit testing.
Who is Participating?
davidlambConnect With a Mentor Author Commented:
After some more work, I've found my own solution.
1. Put the TestFixture within the web application itself. (Otherwise it won't be able to read ANY resx file.)
2. Move Constants.resx out of App_GlobalResources. You can still use it the same way, just from a different namespace (e.g., Code.Constants.resx instead of Resources.Constants.resx).

Simply doing that made everything hunky-dory. I simply wasn't aware that you could have resx files outside of App_GlobalResources. You learn something new everyday!
Bob LearnedCommented:
Are you using NUnitASP?


davidlambAuthor Commented:
Not yet.
Bob LearnedCommented:
I haven't tried regular NUnit with ASP.NET web sites, so I couldn't say that it is even possible.

davidlambAuthor Commented:
Well, given that NUnitASP is simply an extension to NUnit, I would assume that it won't do me any good if I can't use regular NUnit. Plus, I'm not sure I want to bother learning NUnitASP, since nobody's maintaining it anymore (as was announced last Thursday).
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.