Why does VSTest hang for over 45 minutes before running a few unit tests?
I have about 20 unit tests. when I run them from Test Explorer they complete very fast. When I run them on the console with dotnet test
they take more than 45 minutes.
So, I ran dotnet test --no-build -p:VSTestVerbosity=diag -p:VSTestDiag=c:\temp\test.log
. I got two files:
- test.log
- test.host.20-11-24_21-25-00_45838_6.log
The logs show the same pattern. One second later, the first log starts showing
TpTrace Verbose: 0 : 66568, 10, 2020/11/24, 21:25:01.363, 63471109902700, vstest.console.dll, TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: 127.0.0.1:20496 localEndPoint: 127.0.0.1:20495
And will show these messages for the next 44 minutes before successfully completing.
Around the same time the second log starts showing
TpTrace Verbose: 0 : 59460, 10, 2020/11/24, 21:25:02.029, 63471116570605, testhost.dll, TcpClientExtensions.MessageLoopAsync: Polling on remoteEndPoint: [::ffff:127.0.0.1]:20495 localEndPoint: [::ffff:127.0.0.1]:20496
And will be showing such messages for the next 45 minutes as well. After that something clicks and the test completes.
All the tests have SingleThreaded
attribute on their fixture.
Can anyone explain to me what does it all mean?
See also questions close to this topic
-
Add or update entity in EF Core
I have an entity with a recursive relationship like:
public class Message { [Key] public int MessageId { get; set; } public int? ReplyToMessageId { get; set; } public Message ReplyToMessage { get; set; } public ICollection<Message> ReplyMessages { get; set; } }
I need to have an add or update method to save the messages So i write following code:
public void AddOrUpdate(Message message) { if(Context.Messages.Any(m => m.MessageId == message.MessageId)) Context.Messages.Update(message); else Context.Messages.Add(message); Context.SaveChanges(); }
This method make an exception when I pass an existing message with a collection of new replied messages
Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded.
I test
BulkMerge
method of theEntity Framework Extensions
library and it's work fine but I'm looking for a solution with ef core without any extention -
.net core 5 friendly default culture routing
I tried to add multi language feature to my asp.net-core project but there are some changes between .net 3.1 and 5.0 in RequestLocalization and i couldn't get what i want. I added Resource files for each language and I used Resource in my razor pages, its working but there is one unwanted default route bug and i want my routing to work friendly for default culture.
This is what i want,
For default culture (Turkish):
site.com/foo site.com/foo/bar site.com/foo/bar/5
For non-default culture (English):
site.com/en/foo site.com/en/foo/bar site.com/en/foo/bar/5
My other problem is; my route accepts site.com/foo/foo/bar as Turkish culture as well and its not friendly.
My Startup sample code below:
public void ConfigureServices(IServiceCollection services) { services.AddResponseCompression(); services.AddLocalization(opts => opts.ResourcesPath = "Resources"); services.Configure<RequestLocalizationOptions>(options => { var supportedCultures = new[] { new CultureInfo("tr-TR"), new CultureInfo("en") }; options.DefaultRequestCulture = new RequestCulture("tr"); options.SupportedCultures = supportedCultures; options.SupportedUICultures = supportedCultures; options.RequestCultureProviders.Insert(0, new RouteDataRequestCultureProvider()); }); services.AddControllersWithViews(); services.AddRazorPages(); services.AddRouting(options => options.LowercaseUrls = true); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseResponseCompression(); if (env.IsDevelopment()) app.UseDeveloperExceptionPage(); else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); var supportedCultures = new string[] { "tr-TR", "en" }; app.UseRequestLocalization(options => options .AddSupportedCultures(supportedCultures) .AddSupportedUICultures(supportedCultures) .SetDefaultCulture("tr-TR") .RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(context => Task.FromResult(new ProviderCultureResult("tr-TR")))) ); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute(name: "culture-route", pattern: "{culture}/{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllerRoute(name: "default", "{culture=tr}/{controller=Home}/{action=Index}/{id?}"); }); }
Razor Resource usage and culture change navs
Resource files
How can I solve this or what am I doing wrong?
-
accessing httpclient service from within another service in .net 5
I am adding a httpclient as a service (within ConfigureServices(IServiceCollection services)) as follows:
services.AddHttpClient<RequestsClient>(c => { c.DefaultRequestHeaders.Add("User-Agent", "HttpClientFactory"); }) .ConfigurePrimaryHttpMessageHandler(() => { return new HttpClientHandler() { UseDefaultCredentials = true }; });
the RequestsClient class is constructed as:
public RequestsClient (HttpClient client, IHttpContextAccessor hca, ILogger<RequestsClient > log, Configuration config)
to use the RequestsClient service in any class/component needing it i'm injecting it as:
[Inject] protected RequestsClient requestsClient { get; set; }
all this works great.
I'm now in need of creating a second service, lets call it "TimedService". How can I use my RequestsClient service from within my second service, TimedService?
injecting it like i do with components won't work as the RequestsClient always is null. is there a way to give TimedService service access to my RequestsClient service?
I'm sorry if this is a stupid question, I'm fairly new to this
-
How to highlight and scaffold missing unit test?
How can I easily create / scaffold missing unit tests with Visual Studio for Mac.
Ideally something that will prompt us (ideally a build error) that we don't have a unit test for a specific method and will scafold out a test method for us.
The idea is highlight out poor test coverage and make it easier to resolve this.
-
Unit Testing A Class That Use Reflection
I am creating a class called ClassExaminer which uses reflection to read information about properties of the given class. Below is the sample of the class.
public class ClassExaminer<T> { public bool HasWritableProperty(string name) { // Some Code to be put in future. return true; } }
The above class takes a generic parameter of the class that is needed to be examined.
My question is when writing unit tests for this class as I can't create a class inside a method, I will have to create a sample scenario class for each test that I write. And then there will be a lot of private sample classes inside the TestFixture. Will that be a good idea and Should I write a single sample class that will include all the scenarios(properties with specific requirements) and write all tests using that class a sample class for the generic parameter to the ClassExaminer class. Do let me know your views on this, thanks.
-
NUnit 3 test listeners
I'm working on my first C# Selenium-NUnit project, but I have experience in Selenium-TestNG projects. And there was excellent solution for report building by implementing such methods as "onTestStart", "onTestSuccess", "OnTestFailure", "OnTestSkipped" etc of exiting test listener interfaces to realize various reactions on various cases.
Does NUnit contains any listener with similar rich functionality to catch all those events?
-
How can I am filter NUnit tests when running vstest.console.exe
2
1 I have a suite of automated tests (some with SpecFlow, some with NUnit), that I run as part of my TFS build (using visual studio online, with a hosted build agent).
Some of my tests (acceptance tests, not unit tests) cannot be executed on the build server, because they make an assumption about the credentials of the user logged into the system.
I want to be able to filter out these tests from my run, and run everything except for the local-only tests.
In order to achieve this, I added the [Category("LocalOnly")] attribute to the tests to be ignored by the TFS server, and set the test task in the build (new preview build mechanism) to add the following switch: /TestCaseFilter:"TestCategory!=LocalOnly".
Except it doesn't work, even though I believe it should. If I set the filter with the equals sign it runs nothing, and if I use the not-equals sign, it runs everything. It seems that the filter isn't working.
I also tried to run this locally on my box, using vstest.console.exe, with the exact same results, so this is not a problem with TFS).
According to the NUnit adapter for visual studio release notes, this has been fixed, but I see no evidence of it.
Any idea how to fix this?
-
How to do parallel test execution in VsTest
We have using Jenkins as CI tool with VSTest.exe as testrunner. I want to reduce time using parallel with cuurent setup of Jenkins and VStest.
-
Azure DevOps Pipeline: Tests that pass locally with Visual Studio fail on the azure build pipeline with Visual Studio Test Platform Installer
I am facing an issue with Visual Studio Test Platform Installer, a few of my test cases fails when I run through the azure build pipeline using the Visual Studio test platform installer (using version 15.9.0 since my project built on VS 2017).
However, the same works fine with VS 2017 Enterprise locally, I also tried to create an agent in a local machine and pointed the DevOps to use my build agent and selected the option in 'Automated Unit Test task' to use VS 2017 as a 'Test platform version'. It was successful.
Automated Unit Test Task Screen shot
Visual Studio Test platform installer Tasks Screen shot
I checked the logs of Automated Unit test tasks for both cases, both are using 'Test Execution Command Line Tool Version 15.9.0', but still fails when I use Platform installer.
I cant install VS 2017 in the production build machine. Please advise I am getting an exception during Automapper initialization and In addition, in another pipeline, one test case fails due to the null response from the mock object which was successful in the local machine and with the local build agent.
Starting test execution, please wait... [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (32-bit Universal Windows) [xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.1 (32-bit Desktop .NET 4.0.30319.42000) [xUnit.net 00:00:01.13] Discovering: Trans.Services.Trip.Tests [xUnit.net 00:00:01.26] Discovered: Trans.Services.Trip.Tests [xUnit.net 00:00:01.26] Starting: Trans.Services.Trip.Tests [xUnit.net 00:00:02.38] Trans.Services.Vehicle.Tests.TripConversionManagementServiceTests+TheGetTagTripsForConversionAsyncMethod.GetTagTripsForConversionAsync_DatabaseFailure_SqlExceptionThrownAsync [FAIL] [xUnit.net 00:00:02.38] System.Security.VerificationException : Operation could destabilize the runtime. [xUnit.net 00:00:02.38] Stack Trace: [xUnit.net 00:00:02.38] C:\projects\automapper\src\AutoMapper\Mapper.cs(42,0): at AutoMapper.Mapper.Initialize(Action`1 config)