NUnit tests don't run...

Hi-

With VS2008 (and 2005 before it) I'm having trouble getting Resharper 4.1.933.3 to run my NUnit tests. When I attempt to execute a test, the green bar appears but none of the tests are run---all the dots remain grey (see attached image). These tests run fine in the NUnit 2.4.8 GUI.

My Unit Testing configuration is:
Enable Unit Testing
Shadow-copy assemblies being tested (I tried this checked too)
Run tests from: Specified Folder C:\Visual Studio 2008\Projects\MyProject
Enabled unit testing providers: nUnit

Any ideas on what might be happening, or how I can get some more information to debug this?

Thanks,

-Mike



Attachment(s):
nunit_resharper.gif
12 comments

...I think this has something to do with something changing with the way the "Run tests from" folder is interpreted. We compile to the VS default "bin/Debug" folder, but the .config files are read from the project root directory. I can see from filemon that it is finding the config file in the "Run tests from" folder but not the DLL in the bin/Debug folder.

This was working in a previous version of Resharper---is it possible that it reappeared in 4.1?

Thanks,

-mike

0

I'm having this problem too, exactly as described.

I'm using VS 2008 SP1 on Vista Ultimate SP1 and RS 4.1.933.3.

I've also tried disabling all the plugins (Agent Smith and Agent Johnson).

0

Hello Mike,

It didn't change for a long time already, I think since ReSharper 3.0. Could
you please give us a bit more details about config file, dll placement and
overall structure of your test suite? Thanks.

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


MB> ..I think this has something to do with something changing with the
MB> way the "Run tests from" folder is interpreted. We compile to the
MB> VS default "bin/Debug" folder, but the .config files are read from
MB> the project root directory. I can see from filemon that it is
MB> finding the config file in the "Run tests from" folder but not the
MB> DLL in the bin/Debug folder.
MB>
MB> This was working in a previous version of Resharper---is it possible
MB> that it reappeared in 4.1?
MB>
MB> Thanks,
MB>
MB> -mike
MB>


0

FWIW, I downloaded the 4.1.939 EAP yesterday and my unit tests are running now.

0

Hi Ilya,

I have a Solution in VS2008 which has a number of subprojects, e.g.

c:\Visual Studio 2008\Projects\MySolution\Project1
c:\Visual Studio 2008\Projects\MySolution\Project1Tests
c:\Visual Studio 2008\Projects\MySolution\Project2
c:\Visual Studio 2008\Projects\MySolution\Project2Tests
...

These get built into the default Visual Studio directory scheme, i.e.

c:\Visual Studio 2008\Projects\MySolution\Project1\bin\Debug
c:\Visual Studio 2008\Projects\MySolution\Project1Tests\bin\Debug
...

The problem is that these projects expect some .config files to be in the Current directory, which should always be the Solution root

c:\Visual Studio 2008\Projects\MySolution\MyFile.config
c:\Visual Studio 2008\Projects\MySolution\Project2.DLL.config
...

It seems I should be able to set my current directory to the solution root by setting the "Run tests from->Specified folder", but then it tells me it can't find the DLLs. If I select the "Project output folder" it can't find the .config files.

I just upgraded to the 939 EAP but that didn't solve the problem.

This is the .nunit file I'm running in the NUnit 2.4.8 GUI:

]]>


Thanks!

-Mike

0

Hello Mike,

Unfortunately, ReSharper doesn't support NUnit GUI project files. I suggest
creating JIRA issue about your case and we will think about a solution. Here:
http://jetbrains.net/jira/browse/RSRP

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


MB> Hi Ilya,
MB>
MB> I have a Solution in VS2008 which has a number of subprojects, e.g.
MB>
MB> c:\Visual Studio 2008\Projects\MySolution\Project1
MB> c:\Visual Studio 2008\Projects\MySolution\Project1Tests
MB> c:\Visual Studio 2008\Projects\MySolution\Project2
MB> c:\Visual Studio 2008\Projects\MySolution\Project2Tests
MB> ..
MB> These get built into the default Visual Studio directory scheme,
MB> i.e.
MB>
MB> c:\Visual Studio 2008\Projects\MySolution\Project1\bin\Debug
MB> c:\Visual Studio 2008\Projects\MySolution\Project1Tests\bin\Debug
MB> ..
MB> The problem is that these projects expect some .config files to be
MB> in the Current directory, which should always be the Solution root
MB>
MB> c:\Visual Studio 2008\Projects\MySolution\MyFile.config
MB> c:\Visual Studio 2008\Projects\MySolution\Project2.DLL.config
MB> ..
MB> It seems I should be able to set my current directory to the
MB> solution root by setting the "Run tests from->Specified folder", but
MB> then it tells me it can't find the DLLs. If I select the "Project
MB> output folder" it can't find the .config files.
MB>
MB> I just upgraded to the 939 EAP but that didn't solve the problem.
MB>
MB> This is the .nunit file I'm running in the NUnit 2.4.8 GUI:
MB>
MB> MB> MB> MB> MB> MB> MB> MB> MB> MB> MB> Thanks! MB> MB> -Mike MB>]]>


0

Hi-

Sorry, I didn't mean to imply that I wanted to be able to use the project file---I just meant that I want to be able to (a) set the "current directory" to a particular directory while (b) executing a DLL in my bin/Debug directory, where (a) and (b) are different directories. Am I correct in thinking that this should work by setting the "Run Tests From" folder?

Thanks,

-Mike

0

Hello Mike,

No, it doesn't work like this. Setting "base folder" merely sets AppDomain
code base path and then standard .NET assembly loading rules apply. You can
try setting app.config like below. I didn't try that myself, though.

Sincerely, Ilya Ryzhenkov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!" MB> Hi- MB> MB> Sorry, I didn't mean to imply that I wanted to be able to use the MB> project file---I just meant that I want to be able to (a) set the MB> "current directory" to a particular directory while (b) executing a MB> DLL in my bin/Debug directory, where (a) and (b) are different MB> directories. Am I correct in thinking that this should work by MB> setting the "Run Tests From" folder? MB> MB> Thanks, MB> MB> -Mike MB>]]>


0

Hi-

I tried it out but it doesn't seem to work. With Filemon I verified that it was reading the correct .config file with , but it was still looking in the wrong place for the DLLs.

Thanks,

-Mike

0

I also have this problem. It has been working previously but I am not sure at what point it stopped working.

My setup is:

VS 2005 (NET 2 project)
NUnit 2.4.8.0
Resharper 4.1.933.3

Enable Unit Testing checked
Shadow-copy assemblies being tested checked or unchecked
Run tests from: Project output folder
Enable unit testing providers: Nunit

I have tried this on a few differents projects including both Web Application projects and class library projects and they all have the same issue.

0

I've had the same problem today and I was going nuts.
Finally realized what was the cause of the problem: I played around with settings file and app.config was generated. However, the name of the config file seem to be important. After I renamed it to "[AssemblyNameHere].dll.config" it started functioning properly. The location of the file was not changed -> project root.

More in this post: http://jetbrains.net/devnet/message/5122593#5122593

Perhaps this issue should be considered by Resharper authors?

Danko

0

Ugh, I was wrong. So very wrong.. :-)

Renaming app.config to assembly_name.dll.config (even to assembly_name.config) didn't help at all. What happened is that NUnit cannot find those (and any) config files and assumes a blank app.config in the app, so no settings are available. Tests were running and I got green lamps, but afterwards I noticed that settings from external projects waren't overrided by config files.

But now I figured it out. The right config file name is app.config, but the trick is that it's "Copy to Output Directory" flag (in app.config's file properties) has to be "Copy if newer" or "Copy always" (see image in attach). This means that during the project build the copy of app.config gets into the bin folder and resides there with DLLs. That's the place where NUnit is looking for app.config.

My suggestion is to start with a blank settings file and work your way through adding stuff.

Start with a single testing value [ConfigCheck, dummy123]. The application should still work.
Then, build a testing method like this:

[Test]
public void CheckConfigFile()
{
    Assert.AreEqual("dummy123", Properties.Settings.Default.ConfigCheck);
}

You should test this method every time you add something to your app.config.

If using additional external config files and referencing them in section definitions using configSource parameter (for instance <FlexBytes.Graphics.Properties.Settings configSource="config\graphics.config" />) you should set their "Copy to Output Directory" flag as well to "Copy if newer" or "Copy always. You should find this files after the build in "bin" directory (or "bin/config" - depending of your path) - or tests which use this config should break.

So, to conclude: NUnit looks for "app.config" in "bin" folder (like this is the application root) - as well the other (sub-config) files.

Note: running a test doesn't copy config files into the "bin" directory - building a testing project does.

ps. I have: Vista Professional, VS 2008, R# 4.5.

Danko



Attachment(s):
copy_if_newer.gif
0

Please sign in to leave a comment.