[C#] WebClient timeout while doing unit tests
Hi,
I'm using AppVeyor to launch C# unit tests made with XUnit.
I had a few timeout in my code that I wasn't able to reproduce (the timeout is from a WebClient)
Then I saw here https://xunit.github.io/docs/running-tests-in-parallel that you can separate your unit tests in different class to make them run in parallel but since I did this I have even more timeout.
Here's a link to my appveyor.yml: https://github.com/Xwilarg/BooruSharp/blob/master/appveyor.yml
And here's the code of the unit tests: https://github.com/Xwilarg/BooruSharp/blob/master/BooruSharp.UnitTests/Program.cs
I don't think the problem is from my code because when I'm trying it myself I don't have any problem.
(And because I got even more time out since I separated the unit tests into many class)
So if someone would know why the problem occured I would really appreciate :)
Thanks in advance!
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Ilya Finkelshte... on 19 Jul, 2018 10:28 PM
Can you please send a link to the specific build which had this issue?
2 Posted by xwilarg on 19 Jul, 2018 11:03 PM
Here's a link to the last build: https://ci.appveyor.com/project/Xwilarg/boorusharp/branch/master/tests
Support Staff 3 Posted by Owen McDonnell on 20 Jul, 2018 03:34 PM
On my local machine I called a couple of the urls from your failing tests from a powershell WebClient and they returned quickly and without error, so i tried the same script on AppVeyor with one url and that also worked.
So then, I cloned your repo locally, built and ran tests but hit the same WebClient timeout errors as your project does on AppVeyor.
How are you running your tests locally? I see that xunit console runner is not part of your packages.config.
4 Posted by xwilarg on 20 Jul, 2018 04:51 PM
XUnit is available at a NuGet package
https://github.com/Xwilarg/BooruSharp/blob/master/BooruSharp.UnitTests/BooruSharp.UnitTests.csproj#L44
Then I can just open Windows PowerShell and do:
OpenCover.Console.exe -register:user -target:"xunit.console.x86.exe" -targetargs:".\BooruSharp.UnitTests\bin\Debug\BooruSharp.UnitTests.dll -noshadow" -filter:"+[BooruSharp*]* -[BooruSharp.UnitTests*]*" -output:".\MyProject_coverage.xml"
(More informations here: https://github.com/codecov/example-csharp)
But indeed, I think I should post in XUnit forums instead of here, since it's seam more related to XUnit.
Support Staff 5 Posted by Owen McDonnell on 20 Jul, 2018 06:06 PM
Well, I did get the same errors when i ran the tests just with xunit console runner as well.
I was not able to make the command you mentioned work. I got
Target 'xunit.console.x86.exe' cannot be found - have you specified your arguments correctly?
error.6 Posted by xwilarg on 20 Jul, 2018 06:35 PM
Oh, sorry, you need to do this to install xunit in your powershell: choco install xunit
7 Posted by xwilarg on 20 Jul, 2018 10:01 PM
I found the solution of my problem.
I'm now using a HttpClient instead of a WebClient and it's working perfectly.
xwilarg closed this discussion on 20 Jul, 2018 10:01 PM.
Owen McDonnell re-opened this discussion on 20 Jul, 2018 10:29 PM
Support Staff 8 Posted by Owen McDonnell on 20 Jul, 2018 10:29 PM
Ah, of course. That got it to run.
Yet I still get the same timeout errors. I've tested several other url's that cause errors in the tests and a web browser hits them fine.
Support Staff 9 Posted by Owen McDonnell on 20 Jul, 2018 10:30 PM
Oh sorry, missed your last response.
I was actually going to suggest using HttpWebRequest class next.
Looks like you got it sorted anyway.
Ilya Finkelshteyn closed this discussion on 20 Sep, 2018 09:00 PM.