Is there an extension for running `mstest` tests in Visual Studio Code - visual-studio-code

I created a new .NET Core 2.1 solution to learn some new tools. In this solution I have two C# projects: a class library and mstest. I want to run the tests in my mstest project in Visual Studio Code. However, I do not see a way to do this.
I looked through the Visual Studio Code extensions, however, I didn't see an extension that targets mstest projects. Am I missing something?

If you are running .NET Core it looks like you can run unit tests by just typing dotnet tests. There is more documentation MS Docs .NET Unit Testing. But if you wanted to run MS Tests you don't need Visual Studio to do so it comes with its own console, or CLI. Its documented here and more about the command line tool here

Related

Problems with save operation in Visual Studio VSIX custom editor and .Net 6.0 Web application projects

We have built a Visual Studio Extension (VSIX). It is a custom editor for editing a special file that contains definitions for the datamodel in our CMS.
We are porting our CMS to .Net 6.0 from .Net 4.8 ( framework -> core ), however we are struggling getting the editor to work in .Net 6.0 projects. It works fine in web applications written in .Net 4.8, but not in .Net 6.0 web application projects.
Whenever we click the save button in Visual Studio, we get a very general and non specific error message that says: "The operation could not be completed. Unspecified error"
We run the extension with source code in debug mode using the Visual Studio SDK, and there is no exception that is picked up by Visual Studio. ( We use one Visual Studio instance to start another instance of Visual Studio in debug mode, as normal with VSIX projects). Breakpoints etc. work, and we have activated all exceptions in the debugger. When we click save in Visual Studio projects, we get the error message before any method is called in our code. We do not even enter the "IVsPersistDocData2.SaveDocData" method of the "WindowPane" class. The plugin is written in C#. Apart from save, everything works fine. The editor loads fine and function as normal in both types of projects.
There must be some difference in the way the extension integrates with Visual Studio that differ between .Net4.8 projects and .Net6.0 projects. Of course, there are differences in file paths etc in these projects, but I do not see how this is the root of the problem as we do not even get to the stage where any method is called in our editor source code.
As a test I created a very simple extension with only the bare minimum to enable a WindowPane extension, and I get the same error message when saving in 6.0 projects
We created the first version of the plugin back in 2013, using templates from Microsoft and have been updating it for every new version of Visual Studio. There have been some changes in the documentation and projects templates for VSIX, but unfortunately, there is no longer any C# template for custom editors, only C++. (https://learn.microsoft.com/en-us/visualstudio/extensibility/walkthrough-creating-a-custom-editor?view=vs-2022) Pherhaps someone knows any workings examples of custom editors written in c#?
So, we are a little stuck, the error message does not give us any clue to what is wrong. I have not found any documentation that could explain differences in Net 4.8 and Net 6.0 web projects that could cause this.
Anyone had a similar problem? Or perhaps a clue to what is causing this.
(BTW, we are using the latest version of Visual Studio 2022 Community and Windows 11)
After opening a support incident with Microsoft, further investigation and live debugging pointed to problems with VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.SaveItem and a possible internal bug in Visual Studio.
A temporary workaround suggested by Microsoft support, was to add the definition of IPersistFileFormat to the WindowPane implementation. ( None of the methods needed to be implemented. )
This solved the problem for us. The definition of our working WindowPane is now:
public sealed class OntologyDesignerEditorPane : WindowPane, IVsPersistDocData2, IPersistFileFormat, IVsFileChangeEvents

Azure Pipelines - Visual Studio Test does not publish results from TestContext.WriteLine

We are using Azure DevOps to run a build that runs tests using Visual Studio Test.
Everything is working fine, Console.WriteLine lines are being written to Standard Console Output.log, however TestContext.WriteLine are not appearing in the Detailed report.
The same lines are indeed appearing in the Output link on Test Explorer in Visual Studio.
Environment Information
Build Solution: Visual Studio 2017`
VSTest: Latest
Test Framework: MSTest.TestFramework 1.3.2
Test Adapter: MSTest.TestAdapter 1.3.2
Just to reiterate, TestContext is being instantiated correctly, and we are able to check the Output on local machine (Visual Studio 2015 Update 3), however the Ouput will not be published to Azure Pipelines build
Thank you,
Regards

How to debug test from test explorer window in visual studio with Nunit runner

How can I debug my nunit test listed in test explorer in visual studio.I have added nunit adapter and tests are listed in explorer,but if I start debugging fixture from explorer it runs using Vstest.execution engine,is it possible to make explorer use nunit runner?though Vstest.execution engine recognises nunit i want tio run using Nunit runner
When VsTest runs NUnit tests, it is using the NUnit adapter that you have installed, which calls the NUnit execution engine.
Is there something particular that is not working for you in running tests this way that you need some help with?

CI Build Error with Visual Studio Test step after .Net 4.6 upgrade - Executor process exited; There was no endpoint listening at net.pipe

I just upgraded all of the projects in my solution to point to .Net 4.6 (There is a web app, some class libraries, a database project, etc.). I have a CI build set up in Visual Studio Team Services (using the new build system, not XAML) which was building successfully prior to the upgrade. This build definition runs Debug, Staging, and Production builds and the build definition is comprised of two steps:
Visual Studio Build
Visual Studio Test
Prior to this framework upgrade, everything was building fine. I upgraded and built everything locally and it all worked great too. I could run the tests and got green across the board. Now, when I checked my code in it kicked off the CI build, and I got the following error/s on the "Visual Studio Test" step (taken from the logs):
2015-09-18T19:08:02.1212067Z Microsoft (R) Test Execution Command Line Tool Version 14.0.23107.0
2015-09-18T19:08:02.1489666Z Copyright (c) Microsoft Corporation. All rights reserved.
2015-09-18T19:08:02.8906952Z Starting test execution, please wait...
2015-09-18T19:08:03.3713251Z Warning: Using Isolation mode to run tests as required by effective Platform:X86 and .Net Framework:Framework35 settings for test run. Use the /inIsolation parameter to suppress this warning.
2015-09-18T19:08:07.4457804Z ##[error]Error: Executor process exited.
2015-09-18T19:08:07.4457804Z ##[error]
2015-09-18T19:08:07.4557251Z ##[error]Error: There was no endpoint listening at net.pipe:[...redacted...] that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
2015-09-18T19:08:07.4557251Z ##[error]
2015-09-18T19:08:07.7730938Z ##[error]VSTest Test Run failed with exit code: 1
2015-09-18T19:08:07.8043435Z ##[warning]No results found to publish.
The Visual Studio Build passes for all three configurations, and the Test step only fails for Debug because it cannot find any tests for the other two configurations. Additionally, my builds are running off of an Azure VM that I stood up to act as a build server, and when I run the CI build using the Hosted build controller the Test step passes, because it cannot find any tests to execute, but the warning about using 'Isolation mode to run tests...' is still printed out in the log.
Is this a known issue? Has anyone else encountered this after a 4.6 upgrade or in another context in VSTS?
Edit: the .Net Framework 4.6 SDK and targeting pack/s ARE installed on the build machine:
The first warning suggests that the tests are running on .NET 3.5:Warning: ... effective Platform:X86 and .Net Framework:Framework35 ...
So I explicitly set the vstest.console framework version to 4.5. (At this time 4.6 is not an available option). That resolved these symptoms for me.
To do so edit the Visual Studio Test build step. On the Build tab of the step settings, expand the Advanced section, and set Other console options to /Framework:Framework45.
I found a workaround for the time being that works for now. I modified the settings for the Visual Studio Test build step as follows:
On the Build tab of the step settings, expand the "Advanced" section, and change the VSTest version to "Visual Studio 2013".
That's all it took for me. I tried this because my build was working when I switched to the Hosted build controller, and this was one of the differences between the two in the logs. This is the only thing that I changed, and it worked. I have no idea WHY the Visual Studio 2015 VSTest version doesn't work, but will look into it more and add to this if I find anything...
I experienced this error (specifically the VSTest exit code) after upgrading a test project to 4.6.1. The issue was that the packages.config didn't update the test framework runner pacakge correctly leaving it at .Net 3.5. Updating the target framework resolved the problem.
After installing .Net Framework 3.5 feature everything was OK! See "cottsay" comment at https://github.com/Microsoft/vsts-tasks/issues/572

using NuGet with Visual Studio 2005

What would be the most frictionless workflow for working with NuGet and Visual Studio 2005? Is this at all possible? I understand that the plugin is only available for Visual Studio 2010, but there is still the package manager console wich seems to be nothing more than powershell. Can I run the console without Visual Studio and can the console download and integrate packages into visual studio 2005 projects? If so, how is this done?
Scott Hanselman blogged about adding NuGet "support" to Visual Studio 2008. You can probably adapt this slightly to work in Visual Studio 2005 too, though of course you won't get the same experience as in Visual Studio 2010.
Well, not really. A better title would be "How to Cobble Together
NuGet Support for Visual Studio 2008 with External Tools and a
Prayer." The point is, there are lots of folks using Visual Studio
2008 who would like NuGet support. I'm exploring this area and there's
a half-dozen ways to make it happen, some difficult and some less so.
The idea would be to enable some things with minimal effort. It'll be
interesting to see if there are folks in the community who think this
is important enough to actually make it happen. Of course, the easiest
thing is to just use 2010 as it sill supports .NET 2.0, 3.0, 3.5, and
4, but not everyone can upgrade.
Someone could:
Backport the existing NuGet Package References dialog to 2008 using
that version's native extensions (not VSiX)
Create MEF (Managed
Extensibility Framework) plugins for the nuget.exe command-line to
update the references in a vbproj or csproj
Use PowerShell scripts and
batch files to get the most basic stuff working (get a package and
update references.)
Maybe write a shim to get DTE automation
working...
But that's coulds and maybes. Let's talk about the MacGyver
solution. more ยป