Obtaining full nUnit output in visual studio online - c#

I have set up my VS 2013 environment to integrate with TFS in Visual Studio Online. I have configured a CI build to run and then run all my tests (nUnit framework) upon completion. However when the tests complete and I see the output it only says whether each test passed or failed, not the details of the assert statements I call in code, ie what error actually happened.
So it will say
GetPosMenus failed
But if I run the test locally in VS2013 I see the full error
GetPosMenus failed
Initialization method Data.Test.PosMenuDataRepositoryTests.LoadData threw exception. System.ArgumentOutOfRangeException: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index.
at System.ThrowHelper.ThrowArgumentOutOfRangeException()
at System.Collections.Generic.List`1.get_Item(Int32 index)
at Testing.Shared.DataPopulation.Pos.PosMenuDataPopulator.LoadPosMenusIntoDatabase(IUnitOfWork work, IList`1 data, IList`1 venues) in PosMenuDataPopulator.cs: line 48
at5 Data.Test.PosMenuDataRepositoryTests.LoadData() in PosMenuDataRepositoryTests.cs: line 50
How can I configure the online build engine to give me the full output?

You can view this in your account in VSO online and within Visual Studio.
In VS:
Team Explorer Home -> Builds
Under All Build Definitions double-click the build definition you are interested in.
This should open a tab containing a history of completed builds. The default history is set to Today, you will need to change the Date Filter to see older builds. Note also that the visible build history will depend on the retention policy you have set in the build definition.
Double-click your build and you should see the following screen. Expand the test results and the exception should be visible

Related

Could not complete testing: fitnesse.slim.SlimError: Error SLiM server died before Header Message could be read

I am trying to integrate Fitness with Visual Studio 2022. Have .NET 6.0 installed. Following the instructions given in this link. However, every time I run the Test it throws the error
Could not complete testing: fitnesse.slim.SlimError: Error SLiM server died before Header Message could be read. Unable to start test system 'slim': fitnesse.slim.SlimError: Error SLiM server died before Header Message could be read.
Looks like I am missing something very basic about Slim. Please let me know the resolution for this.
I was able to resolve this. The Target Framework RunnerW was pointing to was incorrect. It was pointing to Dotnet4.8. I modified this. But, and included into the fitsharp solution. Then, building solution from Visual Studio kept failing. Identified that this needed updating the Nuget package. Updating kept skipping every time stating the package was already installed. Was unable to build because of these reasons. Was finally able to have breakthrough when I built the solution from cli. Running the Test after this was successful.

Inspect dump files from UWP app

First I enabled saving of dump files on a Windows 10 Mobile phone:
Settings > Update & Security > For developers > Save this many crash dumps: 3
Then I debugged an app which throwed an exception. I continued the debugging after stop. After disconnecting and connecting the mobile phone again, I was able to access the dump file stored under Windows phone\Phone\Documents\Debug directory. The file is called
FPCL.WIndows - a736c773-c105-4b30-a799-4bf317872f5e with exception C000027B on 5-03-2016 12.11.dmp
and has about 140 MB!
I copied the file to the bin directory of my UWP app. Afterwards I opened it as file in Visual Studio 2015 (in the same project). Now I can see the Dump Summary and I have the following buttons:
Debug with Managed Only
Debug with Mixed
Debug with Native Only
Set symbol paths
Copy all to clipboard
If I run Debug with Managed Only I get
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
No compatible code running. The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
In the Watch 1 window I see the following
Name: {CLR}$stowedexception
Value: {"The method or operation is not implemented."}
Type: System.NotImplementedException
This should be the exception I have thrown in my app. When I open this node and look under StackTrace I can get a line number. On pressing Continue I get
The debugger cannot continue running the process. This operation is not supported when debugging dump files.
So I can only stop it.
If I run Debug with Mixed I get again
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
kernelbase.pdb not loaded
kernelbase.pdb contains the debug information required to find the source for the module KERNELBASE.dll
Module Information: Version: 10.0.10586.218 (th2_release.160401-1800) Original Location: KERNELBASE.dll
Try one of the following options: Change existing PDB and binary search paths and retry: Microsoft Symbol Servers
Here I can either press Load or New. So the kernelbase.pdb isn't found under the given location. Should it exists? Where should I find it?
In the Watch 1 window I see the same as above and I can only stop it.
If I run Debug with Native Only I get
Unhandled exception at 0x76ECDF95 (combase.dll) in FPCL.WIndows - f736c883-f105-4d30-a719-4bf328872f5e with exception C000027B on 5-03-2016 12.11.dmp: 0xC000027B: Anwendungsinterne Ausnahme (parameters: 0x075C6838, 0x00000002).
and on clicking Break I get the same missing kernelbase error as above, but here in the Watch 1 window the Value is Unable to evaluate the expression. So I can only stop it.
According to this post I should be able to inspect the source code and find the cause. But how is such a UWP dump file inspected correctly?
You mention
[...] 0xC000027B [...]
[...] $stowedexception [...]
which are both indicators that there is a Stowed Exception inside the dump.
To analyze such exceptions, first watch Channel 9 Defrag Tools, episode 136 where Andrew Richards explains and then analyzes them (at 3:28).
Then download the PDE extension from the Defrag Tools OnDrive and analyze your dump in windbg instead of Visual Studio.
Regarding the symbols of kernelbase, they should be downloaded from the Microsoft symbol server. To set that up in WinDbg, use .symfix;.reload. If you want to give it another try in Visual Studio, go to Debug / Options and choose Debugging / Symbols, then check "Microsoft Symbol Servers".
Regarding the button to press in Visual Studio, choose "Managed only" when debugging the debug build, because your app will run on CoreCLR and choose "Native Only" when debugging the release build, because your app will use .NET native runtime support. (This applies if you didn't change the default settings; otherwise choose according to your compilation settings)

Documentation needed on how to get FXCop running with Sonarqube 5.1

On the sonarqube website the new C# plugin documentation states 'native support for fxcop'
However there is no explanation how to get fxcop running. It does not work out of the box.
What i did so far and works:
installed Sonarqube 5.1
using msbuild.sonarqube.runner
The sonarqube C#,xml,js analysis al work like a charm.
What does not work is using fxcop rules.When i enable 1 rule i get the runner to give the following exception:
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLaunc
her.java:91)
at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102
at org.sonar.runner.api.Runner.execute(Runner.java:100)
at org.sonar.runner.Main.executeTask(Main.java:70)
at org.sonar.runner.Main.execute(Main.java:59)
at org.sonar.runner.Main.main(Main.java:53) Caused by: java.lang.IllegalArgumentException: The property "sonar.cs.fxcop.a
ssembly" must be set and the project must have been built to execute
FxCop ru les. This property can be automatically set by the Analysis
Bootstrapper for Visual Studio Projects plugin, see:
http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of
not built projects, set the property "sonar.visu
alstudio.skipIfNotBuilt".
What i tried so far:
followed the provided docs.codehaus.org/x/TAA1Dg link but this is a dead link. It states "All Codehaus services have been terminated".
added sonar.cs.fxcop.assembly property to the sonarqube.analysis.xml but this does not change anything to the error.
added sonar.cs.fxcop.installdirectory property to the sonarqube.analysis.xml file. This changes the error messages to:
Caused by: java.lang.IllegalArgumentException: Cannot find the
assembly "C:\p
rojects\mercurial\ccvs.sonarqube\bin\sonar-runner\bin\"FxCopCmd.exe""
provided by the property "sonar.cs.fxcop.assembly".
But i'm unable to the the fxcop installation copied to this folder. I also failed to influence the path to be redirected to my fxcop installation which comes with vs2013(C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe)
Another thing is that the sonar-project.properties file next to the .sln file is not picked up by this new msbuild sonar runner thats why i edit the xml file.
In short a step-by-step on the guide how to get fxcop working together with sonarqube 5.1 and the msbuild sonarrunner on the site of sonarqube would be appreciated.
I thinks you should read
http://www.sonarqube.org/easy-analysis-of-visual-studio-solutions-with-the-sonarqube-scanner-for-msbuild/
and
http://docs.sonarqube.org/display/PLUG/C%23+Plugin .
Pay attention to the fact that you should run the commands from a "Developer Command Prompt for Visual Studio 2013 or higher" (http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild).
Neither DOS Command Prompt nor Windows PowerShell work because they don't set the proper variables.
The FxCop native support doesn't mean that it comes with MSBuild SonarQube Runner, but you have to install Visual Studio >= 2013 (as I think you understood from your message).
Moreover, I found that not only sonar-project.properties has been deprecated, but you have to remove it to avoid strange behaviors.

Code Analysis Errors Only on Build Server

I'm trying to figure out why code analysis would run and detect errors on our build server, but I don't see the same errors when building locally. Here is one example of code that's failing (because of our STBi acronym):
string message = string.Format(CultureInfo.CurrentCulture,
"Unit STBi [{0}] blah... ",
unitStbiParameter.Stbi);
The build fails on our TFS build server with errors like this:
CA2204 : Microsoft.Naming :
Correct the spelling of the unrecognized token 'STBi' in the literal
'"Unit STBi ["'.
The problem is that I don't know why I'm not seeing these CA errors when I build the solution on my laptop. This is in the project's properties:
And the build definition has this:
Why would errors show from a build on the build machine but not my laptop? It's almost like the build server is using a different CA rule set. Is that possible?
Side note: I tried adding STBi to the CustomDictionary.xml (below), but that still didn't help. But that's a separate issue.
<!-- This is here because it's a workaround for a bug: http://connect.microsoft.com/VisualStudio/feedback/details/521030/ -->
<DiscreteExceptions>
<Term>STBi</Term>
</DiscreteExceptions>
You probably need to specify the CodeAnalysisCulture MSBuild property in your project(s) (see http://blogs.msdn.com/b/codeanalysis/archive/2007/08/12/new-for-visual-studio-2008-spelling-rules.aspx for an example). Without this set, spelling rules will use the Windows UI culture information for the account under which the analysis is running, which is presumably different for your account and the build account.
Are you building debug locally and release on the Build Server? If so, check that the CA settings are the same for debug and release, and that your dictionary is checked in and the same on the build server.
My team use CA enabled on debug builds and CA is disabled on the build server. The code analysis check-in policy ensures that CA has been run on all code in source control, so is there any point in slowing down your server builds with repeated code analysis passes?

UnitTestIsolationException: Throws Exception while running Shims test in Release/Debug mode

I am trying to run this unit test using Microsoft Shims, but it throws me exception in Shims.Context.Create(); method.
Environment: VS 2012, Win2K8 R2
namespace MyShimsUnitTest
{
[TestClass]
public class MyUnitTest
{
[TestMethod]
public void GetCurrentYear()
{
using (Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create())
{
// Some Logic...
}
}
}
}
Detailed Exception:
Result Message:
Test method MyShimsUnitTest.MyUnitTest.GetCurrentYear threw exception:
Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationException: UnitTestIsolation instrumentation failed to initialize. Please restart Visual Studio and rerun this test
Result StackTrace:
at Microsoft.QualityTools.Testing.Fakes.UnitTestIsolation.UnitTestIsolationRuntime.InitializeUnitTestIsolationInstrumentationProvider()
at Microsoft.QualityTools.Testing.Fakes.Shims.ShimRuntime.CreateContext()
at Microsoft.QualityTools.Testing.Fakes.ShimsContext.Create()
at MyShimsUnitTest.MyUnitTest.GetCurrentYear()
Shims require runtime instrumentation performed by the IntelliTrace profiler. The test runner is responsible for setting up the environment variables required for CLR to load the profiler as well as providing the list of types the profiler must instrument for Shims. The UnitTestIsolationException is thrown when the ShimRuntime is unable to locate and attach to the IntelliTrace profiler, which it expects to be already loaded by the CLR.
As Jin-Wook mentioned earlier, this problem occurs when the test is executed by a runner that does not perform the required profiler initialization. Test Explorer and the vstest.console.exe are two such runners that ship with Visual Studio 2012. At this time, the Visual Studio test runners do not perform the required profiler instrumentation when running tests in "legacy" mode, which happens when you have a .TESTSETTINGS file selected for your run or a .RUNSETTINGS file that forces legacy mode.
You may be able to use third-party test runners that support profiler instrumentation required by Shims.
I had the same issue. The solution to my problem was to uncheck the selected .testsettings file from the menu: TEST/Test Settings and here the item(s) above the Select Test Settings File.
It could be caused by not using the test explorer of vs 2012. To use the shim, you should run tests only using the test explorer.
You can use other test framework such as Nunit or Xunit with the shim if installing appropriate test runner for vs 2012. It can be downloaded from the vs extension manager.
I ran into this issue too. Thankfully the other answers here helped me fix my issue:
I'm using Resharper and when using the context menu I noticed that the runner is using MSTest. Even when finding the test in test explorer and selecting debug I received the same exception.
I then went into Resharpers's options and under Tools -> Unit Testing -> MsTest I unchecked "Enable MSTest support". This unfortunately disables the option to right click on your test and hit run/debug, but it did allow ShimsContext.Create() to behave correctly when selecting debug from the Test Explorer view!
Go to your TestProject Properties -> Under Debug section Check the "ENABLE NATIVE CODE DEBUGGING" checkbox.
This is should do.
We saw this error reported by Bamboo, our build server. It was invoking an MSbuild 4.0 task. The unit test work fine on the dev's local PCs. I deleted this bamboo task and created a new task that invokes Visual Studio 2012's vstest.console. The tests now pass but Bamboo is not able to count the number of tests. This is a Bamboo problem not mine.

Categories