tag:help.appveyor.com,2012-11-13:/discussions/problems/15020-xunit-test-execution-hangsAppVeyor: Discussion 2018-10-19T08:18:50Ztag:help.appveyor.com,2012-11-13:Comment/456420702018-07-07T16:36:03Z2018-07-07T16:38:48ZxUnit test execution hangs<div><p>There are some very weird behaviour here. I've been tinkering around with disabling test specifications, and I got it to run successfully when 1 out of 3 test specifications are disabled. To me this makes no sense.</p>
<p>Take a look at this build that success (2 out of 3 test specifications enabled): <a href="https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-web-application/build/1.0.18">https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-we...</a></p>
<p>Here I enable the third test specification and Appveyor hangs during test execution.<br>
<a href="https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-web-application/build/1.0.19">https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-we...</a></p>
<p>What is going on here? Is there any way to get logs from the client running the tests?</p>
<p>All of the tests in the 19 builds I've executed succeeds locally, so something weird is going on in the test execution process on the appveyor host.</p>
<p>EDIT: Here is the commit history of the repository, so you can see the changes I've made between the working build and the hanged build: <a href="https://github.com/Fresa/Test.It.While.Hosting.Your.Web.Application/commits/master">https://github.com/Fresa/Test.It.While.Hosting.Your.Web.Application...</a></p></div>fresatag:help.appveyor.com,2012-11-13:Comment/456420702018-07-08T04:52:49Z2018-07-08T04:52:49ZxUnit test execution hangs<div><p>try to run tests in a single thread with custom test script like this:</p>
<pre>
<code>%xunit20%\xunit.console.x86 "C:\projects\test-it-while-hosting-your-web-application\tests\Test.It.While.Hosting.Your.Web.Application.Tests\bin\Release\net47\Test.It.While.Hosting.Your.Web.Application.Tests.dll" -appveyor -maxthreads 1</code>
</pre>
<p>I see that you are using UI, so you need to switch to <code>SCRIPT</code> from <code>AUTO</code> in <code>Tests</code> tab and add this command.</p>
<p>Let us know how it goes.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456420702018-07-08T10:22:43Z2018-07-08T10:22:43ZxUnit test execution hangs<div><p>Thanks for your reply!</p>
<p>It did what you said, but it made no difference:<br>
<a href="https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-web-application/build/1.0.20">https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-we...</a></p></div>fresatag:help.appveyor.com,2012-11-13:Comment/456420702018-07-10T02:54:07Z2018-07-10T02:54:20ZxUnit test execution hangs<div><p>Check <a href="https://github.com/Fresa/Test.It.While.Hosting.Your.Web.Application/pull/2">PR</a> and <a href="https://ci.appveyor.com/project/Fresa/test-it-while-hosting-your-web-application/build/1.0.21">build</a>. You can revert from test script back to auto-detection if you merge this change.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456420702018-07-10T07:12:48Z2018-07-10T07:12:48ZxUnit test execution hangs<div><p>Turning off parallel test execution is not really a solution in this case since parallel test execution works. Locally I run the tests in parallel within the test assembly, both with the xunit console runner and ncrunch, and it works fine.</p>
<p>This repo is a testing framework. Being able to run tests in parallel is quite important.</p></div>fresatag:help.appveyor.com,2012-11-13:Comment/456420702018-07-10T20:15:04Z2018-07-10T20:15:04ZxUnit test execution hangs<div><p>Right, it works OK on AppVeyor too if I spin up "Premium" build VM (which is in beta testing now) with 4 cores for this build. <a href="https://www.appveyor.com/docs/build-environment/#build-vm-configurations">Standard build VMs</a> have 2 CPU cores. I am quite sure that your development VM has more than 2 cores too. Also it is pretty possible (though I can be mistaken) that if you run the same tests on some another VM outside of AppVeyor with 1 or 2 cores, you will see the same issue.<br>
Definitely it is a bug somewhere, not necessary in AppVeyor or your tests. We are investigating this, but it can easily happen that another xunit or .NET update will fix it before we even understand what it was.<br>
PR was to unblock you. If you want to be able to run tests in parallel locally, but still have AppVeyor build, you can create or update <code>AssemblyInfo.cs</code> on the fly at the <code>init</code> stage of the build with say PowerShell script.</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456420702018-07-11T21:17:37Z2018-07-11T21:17:37ZxUnit test execution hangs<div><p>I solved the issue! It was due to how xUnit synchronization context works with async/await in parallel test mode. There is a long discussion about it here: <a href="https://github.com/xunit/xunit/issues/864">https://github.com/xunit/xunit/issues/864</a></p>
<p>Really tricky stuff to understand without deep knowledge how xUnit has implemented it's test parallelism concept. Some documentation would have been nice atleast :)</p>
<p>Anyhow, I rewrote my application and the tests, and now everything runs smoothly during the build!</p>
<p>Thanks for your help! I really appreciate your support!</p></div>fresatag:help.appveyor.com,2012-11-13:Comment/456420702018-07-11T21:40:15Z2018-07-11T21:40:15ZxUnit test execution hangs<div><p>Oh, great! Will look deeper at <a href="https://github.com/Fresa/Test.It.While.Hosting.Your.Web.Application/commit/88ece5e4adb4224bbc73514df7622a5202a8bc19">your commit</a> and recommend this to other customers when needed, if you don't mind :)</p></div>Ilya Finkelshteyntag:help.appveyor.com,2012-11-13:Comment/456420702018-07-11T21:47:15Z2018-07-11T21:47:15ZxUnit test execution hangs<div><p>Knock yourself out :)</p></div>fresa