I recently created a unit test project(.net framework) in my project(.net framework 4.8).
I run my tests with visual studio enter image description here.
now wanna add a stage to my ci/cd on gitlab to run my tests.
I know how to do that in .net (dotnet test) but I don't know how to run my tests for .net framework with command line
I'll be happy to know your solutions.
Tnx
The VSTest.Console.exe tool can be used to run unit tests. This is equivalent to using the Visual Studio Test Explorer window.
VSTest.Console.exe is installed with Visual Studio. It is also available in the Microsoft.TestPlatform NuGet package.
(As a note for the benefit of users of Azure DevOps, Azure DevOps pipelines has a Visual Studio Test Platform Installer task that will install the test runner. The Azure DevOps task uses the NuGet package.)
For .net framework you should get familiar with MSBuild. If you are using MSTest you also need to know VSTestConsole. Not too hard!
Here is a minimal GitLab CI config for a .Net framework solution.
Also check here for more detials.
Related
I tried find and use a open source framework for start BI project with TDD .
I choose SSISUNIT for step one. ssisUnit is a unit testing framework for SQL Server Integration Services. It is loosely based on the xUnit family of unit testing frameworks, but is tailored to better support the SSIS environment.
Download SSISUNIT project and run solution 2017 in VS. But I've error when sln open.
Problem :
I tried :
Install the latest version of SSDT recommendation (in this question)
I have SQL Server Integration Services Project, Microsoft reporting service project, Microsoft analysis service project
Read same question but not worked for me in vs 2019.
I tried changed the Project platform to x86,x64 and AnyCPU.
We use SQL-SERVER 2019 SSIS SSAS(MDX), Visual Studio 2019, Power BI
You'll need to remove or unload that project from the solution. Microsoft deprecated support for the setup projects.
I'm trying to run tests via the command line using the NUnit Console Runner:
https://github.com/nunit/docs/wiki/Console-Runner
I have installed https://www.nuget.org/packages/NUnit.ConsoleRunner/ NUnit.ConsoleRunner in my NuGet
I have opened up the command line location in \sanitized\bin\Debug\netcoreapp2.1. I run my test using the command NUNIT3-CONSOLE myTests.dll as mentioned in https://github.com/nunit/docs/wiki/Console-Command-Line
But I get the error:
NUNIT3-CONSOLE: command not found
What command should I use?
Note: This is a .netcore application
NUnit Console is currently unavailable for .net core:
NUnit Console is compiled using the full .NET Framework and does not
currently support .NET Core. To run .NET Core tests from the command
line, you need to use dotnet test. For info on how to do this, see
https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
We are looking at creating a .NET Core based console runner, but it is
still in the planning stages.
Source: https://github.com/nunit/nunit-console/issues/487
Just use dotnet test as described in nunit wiki.
My organization has a large number of legacy test code that is all set up to run on MSTest V1. And until they all have been migrated to MSTest V2, nobody is allowed to MSTest V2.
Now I have run into an unexpected problem. I need to create a new test project, but I can not find a way how to create a new MSTest V1 project in Visual Studio 2017.
In both .NET Core and .NET Framework, it creates a project with MSTest V2. And when I manually try to uninstall the MSTest V2 NuGet Packages and add a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll it seems that that DLL is actually missing.
Is there a way to get MSTest V1 functionality working like this? Because the existing projects work perfectly fine.
Thank You!
So I am not sure myself why I couldn't find the DLL on the first attempt. When creating another project from scratch, the Quality Tools DLL was snuggly available. Once I picked that one and removed MSTest v2 it worked just fine!
I am using .NET framework 4.5 and C# for my project and i used mstest for Test project. All unit test cases ran fine on Visual Studio 2017 enterprise edition, but when I created Jenkins for the Unit test, some of tests are executed and in middle the build fails saying:
No test is available in
\PKGS\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.
Make sure that test discoverer & executors are registered and platform
& framework version settings are appropriate and try again
Additionally, path to test adapters can be specified using
/TestAdapterPath command. Example
/TestAdapterPath:. vstest.console.exe
F:\jnks\workspace\mPrint_Roam_Horizon_Inc\PKGS\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
/InIsolation /EnableCodeCoverage
The error says that the file Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll does not contain any tests (which is correct, because it is a frameworkfile). You probably have some errors in the path where you are looking for dll's with tests in them.
I spent far too much time trying to run a basic NUnit test on a Microsoft Store app. I installed NUnit v3.0.1 and NUnit3TestAdapter on VS2015 Pro but I get the following which confirms that the test is not discovered:
------ Discover test started ------
NUnit Adapter 3.0.8.0 discovering tests is started
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in <project exe file>
The NUnit 3.0 driver does not support the portable version of NUnit. Use a platform specific runner.
NUnit Adapter 3.0.8.0 discovering test is finished
========== Discover test finished: 0 found (0:00:01.0639991) ==========
The NUnit.Engine.NUnitEngineException error referred to is not helpful because there is no way of exploring where the exception is in my program. The test is a single method with one Assert statement just to test if the setup works so there is nothing complicated. I also don't understand what a "platform specific runner" is. I installed both NUnit and NUnit3TestAdapter thru NuGet Package Manager and I presume installations for relevant platform and version are carried out.
I even tried out installing "NUnit Templates for Visual Studio". This allowed me to create an NUnit project, and interestingly the test within NUnit project is discovered and run. But the downside is that I cannot reference my UWP app project from the working NUnit project, I think because the NUnit project only supports .Net frameworks (up to 4.6.1) not Windows 10 platforms.
I have used NUnit before for non UWP applications without much trouble. Am I missing something or NUnit as yet doesn't support UWP apps?
At the moment you can only test DNX projects with XUnit.
Here is a nice starting point for that.
From the official Asp.Net 5 documentation (which uses the same infrastructure as UWP):
For example, to work with the xUnit test framework, you would
configure the dependencies as follows: [example project.json I dont
want to copy]
As other test frameworks release support for DNX, we
will link to them here.
Since there are no other frameworks linked in the documentation, I assume that there are none that support DNX projects at the moment.
Since this question was originally posted NUnit has developed it's support for testing UWP/Xamarin apps. Check out the nunit.xamarin runners.
Essentially, your tests should be created in either a portable library, or a shared project. This can then be referenced by a UWP project runner, which can be run on the emulator.
If you take the shared project approach, you can also reference this through an .NET 4.5 project, which will allow your tests to integrate with the NUnit VS adapter, and show up in VS. Portable libraries can not yet be run with this runner, however that's in the pipeline.