Skip to content

[WebApplicationFactory - TestContainers] PostgreSqlContainer is not initialized. #256

Answered by gasparnagy
PetrosK-hue asked this question in Q&A
Discussion options

You must be logged in to vote

The IClassFixture<StatusControllerFactory> is an xUnit interface and it is not processed / handled by Reqnroll for binding classes.

Maybe others will provide a better idea, but what comes to my mind is that you can initialize your service from an async BeforeScenario hook. Something like this:

[Binding]
public class StatusControllerFactoryInit
{
  [BeforeScenario(Order = -1)] // making sure that this is the first
  public async Task InitStatusControllerFactory(ScenarioContext scenarioContext) {
    // init factory
    var factory = new StatusControllerFactory();
    await factory.InitializeAsync();
    // register it for other binding classes
    scenarioContext.ScenarioContainer.Register…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@PetrosK-hue
Comment options

@PetrosK-hue
Comment options

@PetrosK-hue
Comment options

@gasparnagy
Comment options

Answer selected by PetrosK-hue
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants