Jenkins error during run deployment - unit-testing

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.

Related

How to find the test that caused a timeout

At least one of my tests hangs and causes the test run to abort eventually:
Aborting test run: test run timeout of 7200000 milliseconds exceeded.
Results File: D:\TF\2\s\TestResults\xxxxx.trx
Test Run Aborted.
Total tests: Unknown
Passed: 3261
Skipped: 1
Total time: 2,0003 Hours
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
I'm using TFS 2018 and the Visual Studio Test task (2.3.28) to run unit tests built with Visual Studio 2019 16.4.5.
I started the test task with the additional parameters: /Blame -- RunConfiguration.TestSessionTimeout=7200000
A few days ago, the test suite ran successfully. It typically finishes within 10 minutes:
Results File: D:\TF\3\s\TestResults\xxxxxx.trx
Test Run Successful.
Total tests: 3336
Passed: 3335
Skipped: 1
Total time: 9.0574 Minutes
I examined the .trx file and found the test that was skipped.
But there was no hint about the tests that were skipped due to the abortion and what test caused the time out.
How do I find the problematic test?
Edit:
When examining the .trx file, display the Start Time column and sort it descending. The tests that most recently started may indicate which DLL may be the culprit. Alas, that doesn't provide a definite answer which test(s) were running when the timeout occurred.
If you mean you want information like the screenshot below, you need to use Visual Studio 2019 to do the tests.
The definition looks like below:

Which unit test is currently running?

This question is related to the problem where my unit test procedure is crashing but I don't know on which unit test.
I realise this question is a duplicate of How can I find out which test method in a batch of test methods fails to run? but I need to try anyway:
I'm running some unit tests (about 118 of them), but one of them seems to make the Visual Studio unit test environment crash. This is what I see in the "output" window's "Tests" tab:
[5/02/2018 11:13:18 Informational] ------ Run test started ------
[5/02/2018 11:13:38 Error] The active Test Run was aborted because the execution process exited unexpectedly. The test execution process crashed while running the tests. To investigate further, open file:///C:/Users/DominiqueDS/AppData/Local/CrashDumps/vstest.executionengine.x86.exe.19136.dmp file in Visual Studio and choose "Debug in mixed mode".
[5/02/2018 11:13:38 Informational] ========== Run test finished: 65 run (0:00:19,6926824) ==========
The reason that I have that dump file is thanks to my Windows configuration which automatically creates such dumpfiles in case of a crashing application. (The procedure for this configuration is found under this URL)
Examining the dump file gives me more information on the test, which is failing: I have a hunch where I can find it, and in another thread, I find a function, calling a method which seems to contain the name of the unit test I'm running.
Although I know which test is failing, it's based on hunches and on dumpfiles I should even not generate, so I'm looking for another solution:
In the function TEST_METHOD in the file "c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\VS\UnitTest\include\CppUnitTest.h", I've tried to add the following lines:
cout << "Test : ";\
cout << methodName;\
cout << "\n";\
I was hoping that this would show every test I wanted to run, but instead I get the error message that this is wrong (also using std::cout and OutputDebugString() function seems not to be allowed).
Hence my question: does anybody know a way to find out, in case one of my unit tests makes my test environment crash, how can I find out which test this is, without needing to generate and debug the Visual Studio dumpfile?
For your information: looking in the "Test Explorer" is not helping: I have a list of disabled tests, a list of successful ones, and a list of some which are not finished, and my failing test is not the first of the "not finished" ones.
Found it: I've added the following line in the definition of TEST_METHOD():
Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(L#methodName);\

Running xUnit test under NCrunch --- System.MissingMethodException : Method not found: 'Void Xunit.Assert.Null(...)

I'm trying to get NCrunch up and running with an existing solution in VS 2012. However, the unit tests won't run when initiated via NCrunch.
I get a Method not found: 'Void Xunit.Assert.Null(..) error when attempting to run unit tests under NCrunch.
The test runs when running using xUnit "Run Unit Tests" context menu, or the built-in "Run Tests" from within the IDE.
I've tried cleaning and re-compiling, both in Debug and Release Modes. I've tried debugging the test under NCrunch (it didn't work). I've also checked the GAC for an instance of the xUnit assembly, and it isn't there.
Versions:
NCrunch v2.4.0.2
XUnit Runner for VS 2012/2013 v0.99.3
Visual Studio 2012
Code is in C#
Here is the output from the NCrunch Tests window:
*** ConsoleOutput ***
Unable to read configuration section common/logging. Using no-op implemenation.
*** Failures ***
Exception
System.MissingMethodException: System.MissingMethodException : Method not found: 'Void Xunit.Assert.Null(System.Object, System.String)'.
at XXXX.XXXX.XXXX.XXXXTest.Test_Yada()
Any ideas on how to resolve this problem?

Executing coded UI test from a target machine's mstest(standalone). Dll's/Files needed!! :(

i set up mstest on target machine as standalone program without installing visual studio. So i copied the files(*.exe's,dll's) mstest needed to the target machine and register all dlls in gac which mstest needs to run unit tests.
Works fine so far for normal unit tests.
Acually i try to setup mstest to run coded ui test. I copied some new dll's to the target machine:
- Microsoft.VisualStudio.QualityTools.CodedUITestFramework.dll
- Microsoft.VisualStudio.TestTools.UITest.Common.dll,TestTools.UITest.Extensions.dll
- Microsoft.VisualStudio.TestTools.UITesting.dll
- Microsoft.VisualStudio.HostingProcess.Utilities.Sync
But when i try to execute a test on cmd.exe via mstest.exe on my target machine, the test will run but always fail (works fine on my local machine, Visual Studio 2012). Its a pretty simple test:
- just click on "Start",
- type in "calc press enter"
Both machines use the same operating system.
I guess MSTest.exe still needs some dll's to perform codedUiTests. The bad thing is the missing dll's arent show up in cmd.exe, no errors, no hints just nothing :/
The test runs like normal but will fail all tests.
cmd-output:
Microsoft (R) Test Execution Command Line Tool Version 11.0.50727.1
Copyright (c) Microsoft Corporation. All rights reserved.
Loading D:\Users\Jenkins\Desktop\CodedUITestProject1\CodedUITestProject1\bin\Debug\CodedUITestProject1.dll...
Starting execution...
Results Top Level Tests
------- ---------------
Failed CodedUITestProject1.CodedUITest1.CodedUITestMethod1
0/1 test(s) Passed, 1 Failed
Summary
-------
Test Run Failed.
Failed 1
---------
Total 1
Results file: C:\VS2011Stub\Common7\IDE\TestResults\Jenkins_MSGP166C 2013-05-24 12_36_28.trx
Test Settings: Default Test Settings
Does anyone know what files mstest.exe needs to run codeduitests in a correct way?
Edit: I checked the *.trx file and copied the missing dll's to my target machine.
I tried to run the test again, it failed again. I was checking the trx file again and got an awesome message :/
<Results>
<UnitTestResult executionId="4652eeb1-e1b4-4782-a288-dbd4bb0bda5a" testId="484ddbfe-fdc6-0f5d-9e7b-bab4da5b5905" testName="CodedUITestMethod1" computerName="MSGP166C" duration="00:00:00.0887388" startTime="2013-05-24T16:30:24.1716290+02:00" endTime="2013-05-24T16:30:24.6266745+02:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Failed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="4652eeb1-e1b4-4782-a288-dbd4bb0bda5a">
<Output>
<ErrorInfo>
<Message>Error calling Initialization method for test class CodedUITestProject1.CodedUITest1: System.IO.FileNotFoundException: Das System kann die angegebene Datei nicht finden. (Ausnahme von HRESULT: 0x80070002)</Message>
<StackTrace> bei System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
bei System.Reflection.Assembly.LoadFile(String path)
bei Microsoft.VisualStudio.TestTools.UITest.Framework.UITestExtensionPackageManager.LoadAssembly(String assemblyFile)
</StackTrace>
</ErrorInfo>
</Output>
</UnitTestResult>
</Results>
So what Assembly is missing now?? It was not mentioned.
Thanks in Advance
Instead of trying to copy over the dlls I would install VS Test Agents. It's much lighter than visual studio and will get you mstest. This is the approach I use when running CodedUI tests on a test machine.
http://search.microsoft.com/en-us/DownloadResults.aspx?q=test+agents
Download the version of test agents that you built the project in.
(doesn't really matter)
There will be 3 options when you open the installer. You want test agents.
You should now have everything you need for mstest and codedui
Another that works well is putting all of your codedui tests into an ordered test and passing that into mstest.
MSTest /TestContainer:OrderedTest1.orderedtest
should do the trick

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.