VS 2010, NUNit, and “The breakpoint will not curre

2020-05-24 20:09发布

Using Windows 7 32 bit, VS 2010, .NET 4 DLL, NUnit (2.5.5) to unit test the application. I'm currently getting the following error; seen plenty of posts and tried the following:

  1. restart machine
  2. restart VS
  3. delete bin/obj and reload
  4. clean/rebuild

But I cannot get NUnit to hit my breakpoints when running;

I set the NUNit test project to point to the nunit.exe, and to load the testing .NET 4 DLL, but when I run it doesn't find the breakpoint, "no symbols have been loaded". I tried debug >windows > modules, it doesn't even show my unit testing project when I run it.

I found this, to use the nunit agent: http://groups.google.com/group/nunit-discuss/browse_thread/thread/5680d7def5b6982f

But I get an error when I use the nunit agent too. I was using nunit-agent-x86.exe, but I get a system.formatexception and it crashes...

Can anybody help?

Thanks.

9条回答
2楼-- · 2020-05-24 20:24

Adding the following section in the nunit-x86.exe.config worked for me:

  <startup>
      <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
  </startup>

The 'sku' section is only needed when running with .NET 4's Client Profile. Note that a previous answer showed using 'requiredRuntime' which is obsolete.

查看更多
\"骚年 ilove
3楼-- · 2020-05-24 20:30

If all of the above did not help, open the Properties of your NUnit project in Visual Studio, open "Build" tab, click the "Advanced" button and make sure "Debug Info" is set to "full"

查看更多
Root(大扎)
4楼-- · 2020-05-24 20:33

I was getting "break point will not be hit ... no symbols loaded ..." for a website project. Found that there were build errors in my website (one of the referenced dll's went missing for some reason). Rebuilds didn't show the problem until I selected View=>Error list in VS2010, prior to the rebuild. Replacing the missing dll in the bin dir & updating the reference solved my problem.

查看更多
家丑人穷心不美
5楼-- · 2020-05-24 20:33

I needed to open the NUnit GUI

Tools->Settings->IDE Support [click Visual Studio]

Then in the nunit-x86.exe.config (NOT nunit-exe.config, NOT nunit.agent.exe.config, NOT nunit-console.exe.config),

I needed

   <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0.30319" />
  </startup>

under <configuration>

查看更多
Juvenile、少年°
6楼-- · 2020-05-24 20:35

This problem occurred to me under Visual Studio 2012 Community Edition, when working with .NET Framework 4.5. nunit.exe.config should like this (solution from the most appreciated answer):

<configuration>
    <!--
   The GUI only runs under .NET 2.0 or higher. The
   useLegacyV2RuntimeActivationPolicy setting only
   applies under .NET 4.0 and permits use of mixed 
   mode assemblies, which would otherwise not load 
   correctly.
  -->
    <startup useLegacyV2RuntimeActivationPolicy="true">
        <!-- Comment out the next line to force use of .NET 4.0 -->
         <requiredRuntime version="4.0.30319" />
    </startup>
查看更多
兄弟一词,经得起流年.
7楼-- · 2020-05-24 20:36

The resolution was: start NUnit stand alone, then in VS 2010, do debug > attach to process, and attach to the nunit-agent.exe process, not the nunit process. Nunit process still didn't do it for me.

查看更多
登录 后发表回答