Resharper 8 and Test Explorer not finding xUnit tests in VS2013 - visual-studio-2013

I have the following test code. But cant see the tests in either Test Explorer or Resharper.
What am I missing? I have made the class public, I have tried cleaning the project, i have tried both default architectures in the test settings. I am running Windows 7. xUnit 1.9.2, Resharper 8.1 Full Edition
using Xunit;
namespace MonkeyFace.Specs.Registration
{
public class ValidApplicationReceived
{
[Trait("A valid application is submitted","")]
[Fact(DisplayName= "A user is added to the system")]
public void User_is_Add_To_System()
{
Debug.Print("hi");
Assert.Equal(1,1);
}

Do you have the xunit ReSharper runner extension installed? You need to install it from ReSharper -> Extension Manager.
If it's installed, do you see anything in the editor? Any icons next to the class or method to indicate tests?

I had to install the xUnit.net runner for Visual Studio 2012 and 2013 by using the Tools -> Extensions and Updates menu in Visual Studio

Related

Windows Service Template for Visual Studio 2017

The Windows Service Template no longer displays by-default for new projects in Visual Studio 2017....and the installer has no 'search' capability.
All this AZURE stuff is great, but I still gotta do normal 'on-prem' work too...and I hate maintaining 2 versions of Visual Studio.
Any thoughts here?
Just checked here. I see project "Windows Service (.NET Framework)" under the Windows Classic Desktop folder under Visual C#.
(Visual Basic has a similar entry.)
Only some templates are shown in parent folders, for more specialist templates you need to be more specific.
But also the search finds both.
NB I selected ".NET Desktop" workload on install, which I see you have not.
Check the .NET desktop development option in the installer, then click Modify.
VS2017 --> New project --> Visual Basic or Visual C# --> Windows Classic Desktop --> Windows Service
Also check out this recent post (currently dated 2017-3-30) from MS to do it without the project template:
How to: Write Services Programmatically
The key points are as follows:
Create a new project
Add "System.dll" and "System.ServiceProcess.dll" as References
Create a class inheriting from ServiceBase and create a Program.cs with Main exactly like the template project does
If you are talking Windows Template Studio Universal then You have to install the extension in Visual Studio.
Go to Tools menu >> Extensions & Updates >> Online >>then search for Windows Template Studio
OR go to https://marketplace.visualstudio.com/items?itemName=WASTeamAccount.WindowsTemplateStudio#overview

How to debug in Visual Studio with NSpec

how do I debug in visual studio with NSpec? I've resharper installed I need to step into my test code.
Another good option is to just type
System.Diagnostics.Debugger.Launch()
in the test you want to debug. You'll get a Visual Studio prompt to debug the test.
I would also recommend taking a look at specwatchr.
At least in Visual Studio 2013, the NSpec Test Adapter (by {o} Software) seems to do the trick. Find it in the Extensions gallery. Then just right-click on the test in the Test Explorer and hit Debug.
I use a simple trick that let's me debug NSpec with resharper out of the box. The idea is to have your own version of "nspec" class instead of DebuggerShim.cs (somewhere in your test project):
[TestFixture]
public abstract class nspec: global::NSpec.nspec
{
[Test]
public void debug()
{
var currentSpec = this.GetType();
var finder = new SpecFinder(new[] {currentSpec});
var builder = new ContextBuilder(finder, new Tags().Parse(currentSpec.Name), new DefaultConventions());
var runner = new ContextRunner(builder, new ConsoleFormatter(), false);
var results = runner.Run(builder.Contexts().Build());
//assert that there aren't any failures
results.Failures().Count().should_be(0);
}
}
After that you will get Resharper's test icon next to your spec:
For more details see this article: Debugging NSpec with VisualStudio/Resharper – simple trick
Resharper supports NUnit and MSTest runners only (AFAIR). Open the Resharper "Unit Test Explorer" window and see if it lists your NSpec tests there..
If not, you need to fallback to specifying an external program for debugging (The NSpec runner exe) - See this question on how to configure this in Visual Studio.

Has anyone integrated NUnit with Visual Studio 2010?

Has anyone integrated NUnit with Visual Studio? I'm trying to set up a build pipeline like this one. But, I'm pretty new to .NET and I'm still understanding how things work. There are many resources in the internet on NUnit + VS, and I'm confused.
I'd recommend you to use Resharper.
As some say, "It just works".
Disadvantages/side effects of this choice in your case could be:
1. Resharper is not free;
2. Running unit-tests is minor part of Resharper - it also includes tons of other features, which you maybe do not need for now(but you can disable most of them in setttings).
Free solution is - Visual Nunit 2010 Visual studio extension. Free and does exactly what you want.
UPDATE
How to add NUnit to your project.
I've found this tutorial. Follow it step-by-step, I've found it helpful and complete for .NET novices.
The only difference is that in Running Unit-Tests section for running tests author uses test runner tool that is distributed within NUnit itself, but you can use ReSharper runner as described in JetBrains' docs
I'm using this:
http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
Which works quite well for me. You can access it within VS2010 from View->Other Windows->Visual NUnit
I used TestDriven until it was no longer free, I used Resharper but felt it slowed down my machine too much, I tried the VisualNUnit extension but it appeared to spawn multiple processes of itself that would keep a hold on some of my DLLs, I added NUnit itself as a command under Visual Studio Tools (and also with a toolbar button and some macros in Visual Studio to start the current test and attach) but that cost some effort to set up and didn't feel smooth enough after being spoiled with tools like TestDriven. Eventually I tried NCrunch... I am hooked ever since, and I have even started to favor it over TestDriven! the next tool on my "NUnit bucket list" will be the NUnit extension for Visual Studio 11.
PS: NCrunch should work on your Visual Studio 2010 and the homepage has a very decent demo video.
First download and install the NUnit
Step 1: Open Visual studio
Step 2: Open your project
Step 3: Select Properties from Solution Explorer
Step 4: Select Debug option in the properties window
step 5: select 'Start external program' under the section 'Start Action'
Step 6: Select the path of the NUnit file
Step 7: Save it.
After that when you debug your project NUnit will open.
Setting up Visual C#2010 Express with NUnit
The original and still quite ok test runner.
Test Driven .net
Used to be free, but now costs a small fee unless you're a student or open source developer.
Visual Studio 2011(BETA) is compatible with 2010 and provides test runners out of the box. Refer to Visual Studio 11 Beta Unit Testing – What’s New and Visual Studio 11 Beta - Unit Testing Plugins List. For continuous integration (CI) server U can use TeamCity and also run those test on the server.

Show Visualizers Error "could not load this custom viewer"

When I try to inspect DataSet by standard DataSet visualizer I see this error "could not load this custom viewer".
I wrote simple dataset visualizer, but error throws anyway too.
On other computers with the same configuration visualizer show without any errors.
OS: Windows 7 x86 (Release)
VS: Visual Studio 2010 RC
has somebody any ideas?
I reinstall VS with no effect.
Try the following.
-Go to Tools->options->Debugging->Plz Uncheck "Use Managed Compatibility Mode"
I had the same issue in VS 2015 and none of the answers here helped me but I found an issue on github that described my problem.
The solution, or workaround might be more accurate, for me was to turn off the option "Use the legacy C# and VB evaluators" that I (apparently) had turned on in Tools -> Options -> Debugging -> General.
The best way to diagnose this is to debug Visual Studio itself. Try the following
Get Visual Studio into the state where you want to use your Visualizer
Attach another version of Visual Studio to the original one (managed only)
Disable Just My Code (Tools -> Options -> Debugger -> uncheck "Just my Code")
Go to Debug -> Exceptions
Check the Throw box for "CLR Exceptions"
Switch back to the first VS and Attempt to show your Visualizer
This should throw an exception which will then show up in the second instance of Visual Studio. Please post back with this information if it's not enough to solve your problem.
For me. Visual Studio 2010 restart helped.
I had the same issue in VS2017, I tried a lot but nothing was worked and finally, I reset all the VS settings which I made and the error was gone.
https://blogs.msdn.microsoft.com/zainnab/2010/07/16/reset-all-your-development-settings/
I found workaround!
I changed source code of DevExpress module and recompile it. After that I undo parameter to NetFx40_LegacySecurityPolicy enabled="false", and enjoy. :)
File is "%DeveloperExpress.NET%\Sources\DevExpress.Data\Utils\Security.cs"
using System;
using System.Security;
using System.Security.Permissions;
namespace DevExpress.Data.Helpers {
public static class SecurityHelper {
public static bool IsPartialTrust {
get {
return !IsPermissionGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
}
}
public static bool IsPermissionGranted(IPermission permission) {
bool result = true;
/* (changed by Lion)
try {
PermissionSet ps = SecurityManager.ResolvePolicy((System.Security.Policy.Evidence)null);
ps = ps.Copy();
ps.AddPermission(permission);
ps.Demand();
}
catch (SecurityException) {
result = false;
}
*/
return result;
}
}
}
For me, I had written my own visualizer for a type that I had created. Apparently, this was interfering with VS 2017's ability to display the built-in visualizer for datasets. Once I removed my own visualizer and the Microsoft Debugger Visualizer reference, I could use the built-in ones.
I have written other visualizers in earlier versions of VS that didn't cause any problems.
I found the cause of this error.
According this advice http://go.microsoft.com/fwlink/?LinkID=155570 I add to devenv.exe.config this parameter
NetFx40_LegacySecurityPolicy enabled="true"
and with this parameter in .config file I have the error when try to open DataSet visualizer.
When I remove this parameter all became ok. Execption "The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag" fixed too.
But I NEED NetFx40_LegacySecurityPolicy enabled="true" parameter to work with old projects.
Clearing Visual Studio Cache fixed it for me.
Just follow these basic steps:
Step 1: clear the Component Cache
Close Visual Studio (ensure devenv.exe is not present in the Task Manager)
Delete the directory:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
If step 1 doesn't work then
Step 2: cleanup your user’s temp folder. Delete this directory:
%USERPROFILE%\AppData\Local\Temp
If step 2 doesn't work then
Step 3: Delete all these directories:
%USERPROFILE%\AppData\Local\Microsoft\Team Foundation
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
%USERPROFILE%\AppData\Local\Microsoft\VSCommon
Credit : https://errorhandlinginskills.wordpress.com/2018/07/28/how-to-clear-visual-studio-cache/
visual studio -> Tools-> options-> Debugging-> "Use Managed Compatibility Mode" - uncheck this and maybe it works fine then.
in visual studio 2019 community after an update between 16.4.x - 16.7.5 mine was broken all I had to do was uncheck "Warn when using custom debugger visualizers against potentially unsafe processes (Managed only)" and it allowed me to see a visual of the datatable. Under the tools>options>Debugging>general menu.
Just Restart your system. Your problem will be resolved.

How to debug mbunit/Gallio unit tests in visual studio

I am trying to figure out how I can hit breakpoints in my unit tests that are written with MbUnit/Gallio. I tried running Gallio.Icarus, attaching vs debugger to it, the breakpoints weren't hit.
Next I tried to start Gallio.Echo from project properties, but I was getting an error message, after supplying the dll, saying only .exe's can be tested.
The unit test runs fine from Gallio.Icarus, however, I am unable to debug them.
Thanks!
Grab Gallio v3.0.6 Update 1. Load up your tests and click on the shiny new "Debug" button in the Icarus GUI itself.
I would use TestDriven.Net for this. It supports MbUnit tests, and you can debug by simply right clicking from within Visual Studio
A much better answer is found here:
gallio test runner plugin to visual studio 2010
The answer is to add the following section to your *.csproj file the after the <ProjectGuid> section section:
<ProjectTypeGuids>
{3AC096D0-A1C2-E12C-1390-A8335801FDAB}
; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
</ProjectTypeGuids>
See Also:
How Does Visual Studio Identiy test projects?
A list of supported VS2010 project types
Second list of GuIDs for supported project types

Resources