Repository navigation
Regression in property injection #3958
Copy link
Copy link
Closed
Description
Hi
I'm upgrading from 0.67.4 to 1.3.9. My tests are set up in a fashion as described in #3266 .
The class that initialises the Pulsar container is throwing an exception with the following details:
Failed to inject properties for type 'TestFeature': Failed to inject properties for type 'PulsarBrokerHandlerTestWrapper': Failed to initialize data source of type 'PulsarTestContainer': Docker API responded with status code=InternalServerError, response={"message":"Get \"https://registry-1.docker.io/v2/\": EOF"}
Stack trace: at TUnit.Engine.Services.DataSourceInitializer.InitializeDataSourceAsync(Object dataSource, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, CancellationToken cancellationToken)
at TUnit.Engine.Services.DataSourceInitializer.EnsureInitializedAsync[T](T dataSource, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, CancellationToken cancellationToken)
at TUnit.Engine.Services.PropertyDataResolver.ResolvePropertyDataAsync(PropertyInitializationContext context, DataSourceInitializer dataSourceInitializer, IObjectRegistry objectRegistry)
at TUnit.Engine.Services.PropertyDataResolver.ResolvePropertyDataAsync(PropertyInitializationContext context, DataSourceInitializer dataSourceInitializer, IObjectRegistry objectRegistry)
at TUnit.Engine.Services.PropertyInitializationOrchestrator.InitializeSourceGeneratedPropertyAsync(Object instance, PropertyInjectionMetadata metadata, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
at TUnit.Engine.Services.PropertyInitializationOrchestrator.InitializeSourceGeneratedPropertiesAsync(Object instance, PropertyInjectionMetadata[] properties, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
at TUnit.Engine.Services.PropertyInitializationOrchestrator.InitializeObjectWithPropertiesAsync(Object instance, PropertyInjectionPlan plan, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
at TUnit.Engine.Services.PropertyInjectionService.<>c__DisplayClass7_0.<<InjectPropertiesIntoObjectAsyncCore>b__0>d.MoveNext()
--- End of stack trace from previous location ---
at TUnit.Core.PropertyInjection.PropertyInjectionCache.EnsureInjectedAsync(Object instance, Func`2 injectionFactory)
at TUnit.Core.PropertyInjection.PropertyInjectionCache.EnsureInjectedAsync(Object instance, Func`2 injectionFactory)
at TUnit.Engine.Services.PropertyInjectionService.InjectPropertiesIntoObjectAsyncCore(Object instance, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
Stack trace: at TUnit.Engine.Services.PropertyInjectionService.InjectPropertiesIntoObjectAsyncCore(Object instance, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
at TUnit.Engine.Services.PropertyInjectionService.RecurseIntoNestedPropertiesAsync(Object instance, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
at TUnit.Engine.Services.PropertyInjectionService.InjectPropertiesIntoObjectAsyncCore(Object instance, ConcurrentDictionary`2 objectBag, MethodMetadata methodMetadata, TestContextEvents events, ConcurrentDictionary`2 visitedObjects)
This is only happening after updating the TUnit libraries. The image exists in the remote container registry.
Metadata
Metadata
Assignees
Labels
No labels
Activity
seahurricanelemonade commentedon Nov 30, 2025
Just upgraded to 1.3.13 and its revealed more:
thomhurst commentedon Nov 30, 2025
Can you try v1.3.15 ?
seahurricanelemonade commentedon Nov 30, 2025
Same issue still. Is there a timeout for the properties to be initialised? Maybe that's whats happening?
thomhurst commentedon Nov 30, 2025
Can you give me a test setup to reproduce it?
seahurricanelemonade commentedon Nov 30, 2025
Give this a go: https://github.com/seahurricanelemonade/TUnitIssue3958/tree/main
thomhurst commentedon Nov 30, 2025
Thanks! Takes a lil while to start for me, but ends up passing:
It may be an issue with your machine? The error is Docker returning an error?
seahurricanelemonade commentedon Nov 30, 2025
Hmm thats so strange. If I revert the TUnit version back to 0.67.4, it works again. I'll have a bit more of a play.
seahurricanelemonade commentedon Nov 30, 2025
I've figured it out. The property injection happens before any 'BeforeTestSession' hooks can take place now, whereas previously the hooks ran before property injection.
Ive changed my 'BeforeTestSession' hook to be 'BeforeTestDiscovery'.
seahurricanelemonade commentedon Dec 11, 2025
@thomhurst - Testing the latest version as of now. Are there now retry attempts on property injection if an exception was thrown? I've spotted that my WebApplicationFactory keeps getting called to initialise before a static BeforeEveryTest hook runs and then eventually it initialises successfully because that hook executes as the WebApplicationFactory relies on that hook executing first.
seahurricanelemonade commentedon Dec 11, 2025
Seems fixed by #4049