Experiencing "DEP3000" error when trying to run WinRT unit tests - unit-testing

I am experience this strange error trying to run unit tests for WinRT from Visual Studio 2012.
Error: DEP3000: Attempts to stop the application failed. This may
cause the deployment to fail. App Packages may only be shutdown as
part of a Visual Studio build operation
I don't understand at all what that could mean? I've tried restarting my computer and reinstalling developer license. How I reproduce it is I just create a new empty unit test project from the Visual Studio template. I don't touch the project at all. But, when I try to do Run Tests on it, it just says pending for a a while and then spits out that error
How do I fix this?
Specs: Windows 8 Enterprise 64bit, Visual Studio 2012 with Update 2
Also, I've seen this question about VS2012RC, but the answer doesn't seem to apply. I've tried every configuration of this there is and nothing works past this error

I had same problem when I applied VS upgrade2 AND used Resharper 7.1.1 to run the unittests. Turns out you need to upgrade Resharper to 7.1.3 -- or run the tests with the VS test explorer.

You can just try using XUnits App:
https://channel9.msdn.com/Shows/demooftheday/xunit-in-uwp
With this, test will run on XUnit's test app, not in VS Test Explorer.
In my unit test project's project.json
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
"xunit": "2.1.0",
"xunit.runner.devices": "2.1.0" }, "frameworks": {
"uap10.0": { } }, "runtimes": {
"win10-arm": { },
"win10-arm-aot": { },
"win10-x86": { },
"win10-x86-aot": { },
"win10-x64": { },
"win10-x64-aot": { } }
}
Then go to the XAML file in the unit test project named UnitTestapp.xaml and change it to
<ui:RunnerApplication
x:Class="UnitTestProject1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnitTestProject1"
xmlns:ui="using:Xunit.Runners.UI"
RequestedTheme="Light">
</ui:RunnerApplication>
And of course, in the code behind:
sealed partial class App : RunnerApplication
{
protected override void OnInitializeRunner()
{
AddTestAssembly(GetType().GetTypeInfo().Assembly);
InitializeRunner();
}
partial void InitializeRunner();
}

Related

TestStack White - Run tests from command line

I'm looking for a solution to start my tests from command line.
I created a UnitTest Procjet in VisualStudio2017 for my .NET solution.
Added TestStack.White NuGet package to the project.
The test are running fluently when I start from the VisualStudio2017.
I would like to start it from Jenkins also. I think it is the easiest to do it from command line, so I add it to my pipeline configuration (Jenkinsfile)
stage('Run UI Tests') {
steps {
bat('"C:\\PATH_TO_MSTEST\\mstest" /testcontainer:PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
}
}
When I try to start it from cmd like I would do with with regular Unit Tests, it is not working.
It says:
Starting execution...
No tests to execute.
I build the project before I start 'Run UI Tests' stage.
Any ideas how to make it work? Could really find it on stackoverflow, github issues of TestStack nor other glory places on the web
Found a solution.
On my local developer machine it was working, the mstest version was 14
On the build agent machine the mstest version was 15, that was not working somehow (it had nothing to do with TestStack White, simply the unit tests were not working)
What I do is, calling vstest.console.exe instead of the mstest.
C:\Program Files (x86)\Microsoft Visual Studio\2017\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe
So, instead of
stage('Run UI Tests') {
steps {
bat('"C:\\PATH_TO_MSTEST\\mstest" /testcontainer:PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
}
}
My command in the Jenkinsfile was:
stage('Run UiTests') {
steps {
bat('"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\TestAgent\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe" PATH_TO_MY_TEST_PROJECT\\bin\\Debug\\MyTests.dll')
}
}
nunit3-console is great alternative to MSTEST. Please refer below link.
e.g.
nunit3-console \bin\Debug\Automation.dll --where "cat=Smoke-Tests"
https://github.com/nunit/docs/wiki/Console-Command-Line

Running (x)Unit Tests on TFS Build Pipeline

I am merely a beginner and still trying to learn about TFS and its continuous integration workflow. Having that said, this could as well be a stupid question to ask as I might be missing on a simple detail, though any help or advice would be highly appreciated.
So, I have a fairly simple Unit Test example written using .NET Core 2.0, which I would like to run as a test task on our TFS Server's CI Build pipeline. It pretty much looks something like this:
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MyUnitTest
{
[TestClass]
public class MyUnitTest
{
[TestMethod]
public void PassingTest()
{
Assert.AreEqual(4, Add(2, 2));
}
[TestMethod]
public void FailingTest()
{
Assert.AreEqual(5, Add(2, 2));
}
int Add(int x, int y)
{
return x + y;
}
}
}
When I try to run these tests in Visual Studio, it builds perfectly and the tests succeed and fail accordingly. So I commit my project and push it to our TFS git repository. Now, I similarly would like to integrate these tests in our build pipeline.
The Build Definition used in our CI builds looks like this. I have added Visual Studio Test - testAssemblies task in the build pipeline and configured the search pattern to find the assembly named MyUnitTest.dll and such. When I queue the build, I get the following warning in VSTest's log.
Warning: No test is available in C:\BuildAgent\_work\9\s\MyUnitTest\MyUnitTest\bin\release\netcoreapp1.1\MyUnitTest.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.
So, it seems to me that VSTest somehow cannot find tests to run in the target assembly. I am pretty positive that I might have misconfigured something, or forgotten to set some particular parameter appropriately. I will be more than grateful for any suggestion that would possibly pinpoint what I might be doing wrong.
Searching for solutions online, I have come across this question, which seems to have a similar problem.
First make sure your build agent environment is as same as your local develop machine. Such as Visual Studio version, MsTestAdapter ,xunit runner version and so on.
You could double confirm this by manually run the test directly on the build agent machine not through TFS.
Then use the below tasks in your build pipeline:
Add a dotnet restore task.
Then a dotnet build task.
Add a dotnet test task with the arguments --no-build --logger "trx;LogFileName=tests-log.trx
Add a Publish test results task with the following settings
More details please refer this tutorial blog: Running dotnet core xUnit tests on Visual Studio Team Services (VSTS)

Cannot find element for dotnet test id: error in Resharper 2016.3

I just downloaded Resharper 2016.3 EAP 4 to check out the Unit test functionality with .NET Core. But when I run all unit tests, I get this error:
Cannot find element for dotnet test id:
MvcMovieTests.SimpleTests.TestMethodPassing
Cannot find element for dotnet test id:
MvcMovieTests.SimpleTests.TestMethodFailing
Here are my simple unit tests:
[TestClass]
public class SimpleTests
{
[TestMethod]
public void TestMethodPassing()
{
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(true);
}
[TestMethod]
public void TestMethodFailing()
{
Microsoft.VisualStudio.TestTools.UnitTesting.Assert.IsTrue(false);
}
}
When I run all unit tests with the MSTEST Test Explorer, they run properly and I see the results. But with Resharper 2016.3 I get the two errors above showing up in the Unit Test Sessions window in Visual Studio 2015 Community.
Clearing up the ReSharper caches fixed it up for me. Open the Environment | General page of ReSharper options. Click Clear caches. More information here.

Issues using DataTestMethod and DataRow attributes in MS Test

I have installed MS Test V2 in my VS 2015 instance using nuGet and I have successfully added DataTestMethod and DataRow attributes to my unit tests and they compile, but now when I build, the tests don't show up in Test Explorer.
Example:
[DataTestMethod]
[DataRow("YAHOO", "GOOGLE")]
public void TestCheckSite(string site)
{
... do stuff here ...
}
What am I missing? Is there a Test Explorer upgrade?
[DataTestMethod]
[DataRow("YAHOO")]
[DataRow("GOOGLE")]
public void TestCheckSite(string site) {
...
}
Install MSTest Framework: https://www.nuget.org/packages/MSTest.TestFramework/
If you are building for .NET Core, then install this adapter: https://www.nuget.org/packages/dotnet-test-mstest/
However, if you are building for desktop .NET/UWP, install this adapter instead: https://www.nuget.org/packages/MSTest.TestAdapter/
Now write the tests and build your solution. The tests ought to show up in the Test Explorer.
Please let me know if you still do not see the tests showing up.

xUnit Test Runner failed to run tests through ReSharper

Visual Studio 2015 Enterprise Update 3, all KB package updates are applied
ReSharper 2016.1.2, latest
According to my project.json file xunit references are;
"xunit": "2.2.0-beta2-build3300",
"xunit.abstractions": "2.0.1-rc2",
"xunit.assert": "2.2.0-beta2-build3300",
"xunit.extensibility.core": "2.2.0-beta2-build3300",
"xunit.extensibility.execution": "2.2.0-beta2-build3300",
"xunit.runner.console": "2.2.0-beta2-build3300",
"xunit.runner.visualstudio": "2.2.0-beta2-build1149",
"xunit.runners": "2.0.0"
.Net framework is 4.5.2
.Net Core Solution type which means .xproj
When i try to use ReSharper xUnit test runner, i'm encountering;
"Unit Test Runner failed to run tests, Unable to run xUnit tests -
File not found:"D:\srcs\GitProjects..etc\bin\My.Tests.dll"
Parameter name: assemblyFileName
Sorry for Turkish exception details, i couldn't change yet.
Any idea about that? I searched a lot of forums and i couldn't find any useful stuff. Thanks in advance.
Support for .NET Core testing in Resharper is scheduled for 2016.3
The workaround is to use Visual Studio Test Explorer. (Test --> Windows --> Test Explorer)
The project.json file must contain xunit and dotnet-test-xunit:
{
...
"testRunner": "xunit",
"dependencies": {
...
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
},
...
}
Rebuild your project and you should be able to successfully run your tests.
If you have Visual Studio 2015 you can start your test inside the code.
Update: (2017-02-08)
It also works with nunit;
{
"testRunner": "nunit",
"dependencies": {
...
"NUnit": "3.5.0",
"dotnet-test-nunit": "3.4.0-beta-3"
},
...
}
ReSharper doesn't currently support .net core testing. This is scheduled for 2016.3.
By installing the Early Access Program(2016.3) of Resharper, you will be able to run your dotnet core tests.
It supports both nunit and xunit.
I installed it, and it solved the issue for me.
Link to the relase details:
https://blog.jetbrains.com/dotnet/2016/09/26/resharper-ultimate-2016-3-eap-build-1-details/