UWP Unit Test App starts but no tests run - unit-testing

I can't get UWP unit tests to run for our project. The app starts, then closes, and in the Test output there is an error:
[4/11/2018 7:36:42 Informational] ------ Run test started ------
[4/11/2018 7:37:05 Error] An exception occurred while invoking executor 'executor://mstestadapter/v2': Value cannot be null.
Parameter name: key
[4/11/2018 7:37:09 Informational] ========== Run test finished: 0 run (0:00:26.8121266) ==========
I tried deleting the .vs folder, all the bin and obj folders, and restarting Visual Studio.

Related

Unit Tests not discovered and executed in Visual Studio 2017 when legacy test settings specified

I'm using Visual Studio 2017 Professional 15.4.5 and I found out unit tests will not be discovered when legacy .testsettings is loaded via selecting it in the Test > Test Settings > Select Test Settings menu
Here are steps to reproduce it:
Create a new Solution
Create a Class Library project with target framework .NET Framework 4.5.2 with following simple class:
public class Class1
{
public bool True => true;
}
Create a Unit Test Project(.Net Framework) with target framework .NET Framework 4.5.2 and setup project reference and write a simple test:
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
Assert.IsTrue(new Class1().True);
}
}
Run the test, the test should be discovered and run
Use solution context menu to select Add > New Item, select Test Settings in the left pane and select Test Settings in the middle to create a new test settings.
Skip the setting by just closing the dialog. Set the test settings by clicking the menu Test > Test Settings > Select Test Settings
Run the test again, it was not executed and some information can be seen in the Output pane:
[2017/12/08 13:36:20 Informational] ------ Run test started ------
[2017/12/08 13:36:22 Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
[2017/12/08 13:36:22 Error] Test adapter sent back a result for an unknown test case. Ignoring result for 'TestMethod1'.
[2017/12/08 13:36:22 Informational] ========== Run test finished: 0 run (0:00:01.9851985) ==========
Updates
To answer #aruna I followed my own instructions again with VS2017 Professional 15.5.7
The test still failed to run but the output is different:
[2018/03/01 13:39:13 Informational] ------ Load Playlist started ------
[2018/03/01 13:39:13 Informational] ========== Load Playlist finished (0:00:00.001) ==========
[2018/03/01 13:40:46 Informational] ------ Discover test started ------
[2018/03/01 13:40:48 Informational] ========== Discover test finished: 1 found (0:00:02.1855628) ==========
[2018/03/01 13:40:48 Informational] ------ Run test started ------
[2018/03/01 13:40:49 Informational] ========== Run test finished: 1 run (0:00:01.5406918) ==========
[2018/03/01 13:41:32 Informational] ------ Run test started ------
[2018/03/01 13:41:34 Warning] Warning : A testsettings file or a runsettings with a ForcedLegacyMode set to true is not supported with the MSTest V2 Adapter.
[2018/03/01 13:41:34 Warning] No test is available in D:\git\demo\unit-test-legacy-settings\UnitTestProject1\bin\Debug\UnitTestProject1.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
[2018/03/01 13:41:34 Informational] ========== Run test finished: 0 run (0:00:02.0727927) ==========

Discover Tests Runs Twice in xUnit

I have my solution setup whereby there is one xUnit test project/assembly configured within that solution that has an xUnit desktop runner.
When I run the tests of this solution by running "Run All" in the Test Explorer window, I see the following output:
------ Discover test started ------
[xUnit.net 00:00:00.6641444] Discovering: Namespace.Testing
[xUnit.net 00:00:01.7346388] Discovered: Namespace.Testing
========== Discover test finished: 255 found (0:00:02.2705091) ==========
------ Run test started ------
[xUnit.net 00:00:00.7718801] Discovering: Namespace.Testing
[xUnit.net 00:00:01.9540699] Discovered: Namespace.Testing
[xUnit.net 00:00:02.6006763] Starting: Namespace.Testing
[xUnit.net 00:00:13.1270643] Finished: Namespace.Testing
========== Run test finished: 255 run (0:00:17.5635971) ==========
There appears to be a "Discover test" step and a "Run test" step being executed, where the "Discovering" and "Discovered" steps are being executed for each step, making it appear that they run twice.
I am curious if this is being run by design or if I have an errant setting somewhere that is causing this behavior. It seems to me (or would be expected) that the "Discovering/Discovered" would only occur once per run. As you can see, it is adding an additional 2 seconds to each run and I would like to avoid that if possible.
First "Discovering" comes from the "Test Explorer" trying to discover tests.
And the second one is from the "XUnit Visual Studio Runner".
When running test on e.g. TFS Server, it will only run "Discovery" once.

Jenkins error during run deployment

Hi I was running my unit test in Jenkins when I encountered this error
Results Top Level Tests
------- ---------------
Failed FailedTest1
Failed FailedTest2
Failed FailedTest3
0/3 test(s) Passed, 3 Failed
Summary
Test Run Failed.
Failed 3
Total 3
Results file: C:\Program Files (x86)\Jenkins\workspace\BatchTests\BatchTestsResult
Test Settings: Default Test Settings
Run has the following issue(s):
Warning: Test Run deployment issue: The assembly or module 'Microsoft.Practices.ServiceLocation' directly or indirectly referenced by the test container 'C:\Program Files (x86)\Jenkins\workspace\BatchTests\mml\bin\release\syncfromgbaseeucbatchtests.dll' was not found.
Build step 'Run unit tests with MSTest' marked build as failure
Finished: FAILURE
what is even worse that I do not unstand is that I did not have the reference of Microsoft.Practices.ServiceLocation specified in my project reference, therefore i do not know why the dll is looking for it.
The unit tests however do run properly from visual studio 2012 instead. Any help is appreciated.

Cannot open DefaultTest.dll for unit test

When I try to run my unit test in VS 2012 I get the following error:
1>------ Build started: Project: Tests, Configuration: Debug Win32 ------
1>LINK : fatal error LNK1104: cannot open file 'C:\Users\Patryk\Documents\Visual Studio 2012\Projects\LUT\Debug\DefaultTest.dll'
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
It works again, when I restart VS but then I get the same error after I have to rebuild the project
"DefaultTest.dll" is a remnant of not changing the Target Name in the project's General Configuration Properties.
The same thing happens to me in Visual Studio 2010. Removing the .dll and .dll.metagen files from the output directory and rebuilding the test project solved the problem in my case.
I get this error if the testing engine is still running in background.
Check if the vstest.executionengine.x86.exe process is still running in background, and kill it if so. Afterwards you can rebuild and run your tests.

Windows 8 store app unit tests fail in VS 2012

I am developing a Windows 8 store app. I added unit tests by choosing Solution >> Add >> new project >> Unit Test Library (Windows Store apps). I am then able to run the tests fine.
However, I then add a reference to my original Windows 8 store app project (following the instructions here), and when I try to run the tests again, I get the following error:
------ Discover test started ------
WriteTestCaseStarted
WriteTestCase Took Time = 3.0004
========== Discover test finished: 1 found (0:00:00.1350024) ==========
------ Run test started ------
Updating the layout...
Copying files: Total <1 mb to layout...
Registering the application to run from layout...
Deployment complete. Full package name: "c078c431-2a0d-4494-8dd9-47ae01ac938d_1.0.0.0_neutral__chny7cy2kxrnj"
Exception has been thrown by the target of an invocation.
========== Run test finished: 0 run (0:00:01.8770198) ==========
What am I doing wrong?
Update: Commenting out the following line from App.xaml solved the problem:
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
Why?
Multiple things can cause this. Here are a couple I've found:
Application tag in app.xaml setting any properties (like RequestedTheme)
App.xaml referencing a ResourceDictionary which uses custom attached properties.
Try commenting out contents of App.xaml to see if that helps.