Search code examples
sql-serverunit-testingdebuggingsql-server-2012sql-server-data-tools

Unable to debug TSQL from unit test in SSDT


Steps to reproduce

1.Create stored procedure under (localdb)

enter image description here

2.Define body and place brake point

enter image description here

3.Update changes to project (through schema update)

enter image description here

4.Create unit test (in the project menu)

enter image description here

5.Define unit test body

enter image description here

6.Debug unit test

enter image description here

As a result - nothing happens... breakpoint (from step 2) is not firing at all.

Output window produce next output:

*Done building target "SqlDeploy" in project "test3.sqlproj".
Done building project "test3.sqlproj".
Build succeeded.
C:\Users\amorozov\Documents\Visual Studio 2012\Projects\Trash\test3\test3\bin\Debug\test3.sql : Deploy warning SQL72030: The project and target databases have different collation settings. Deployment errors might occur.
    1 Warning(s)
    0 Error(s)
Time Elapsed 00:00:07.73
Executing test script...
1 batches, 2 ResultSets, 2 rows affected
Validating scalarValueCondition1
The thread '.NET SystemEvents' (0x1938) has exited with code 0 (0x0).
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>vstest.executionengine.x86.exe</AppDomain><Exception><ExceptionType>System.AppDomainUnloadedException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Attempted to access an unloaded AppDomain.</Message><StackTrace>
</StackTrace><ExceptionString>System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.</ExceptionString></Exception></TraceRecord>
The thread 'In-proc Node (Default)' (0xcc8) has exited with code 0 (0x0).
The thread '<No Name>' (0x1b54) has exited with code 0 (0x0).
The program '[6040] vstest.executionengine.x86.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).*

The only strange thing I see in output - <ExceptionString>System.AppDomainUnloadedException: Attempted to access an unloaded AppDomain.</ExceptionString>

I am able to reproduce this behavior both at work and at home. Both systems a the same:

  • VS2012 Premium (update 3)
  • Windows 8 64 bit/Windows Server 2012 64bit

enter image description here

Someone has this feature working?

What I'm doing wrong?


Solution

  • Thanks for raising this - this appears to be a bug in SSDT and we have created a defect to track this issue. You should still be able to debug your stored procedure from a "New Query" window - see the steps listed here. However at present it looks like you cannot debug into the stored procedure during unit testing.