Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

150
Visualizações
How to have integration test project use a different connection string?

I have connection strings set up in an app.config file, with different files for debug and release based on this SO answer. I'm setting up an integration test project which should be using a different initial catalog for the tests. How do I get the project, and only the integration test project, to use a different connection string?

Edit: Trying to add some more detail. In app.config I have the following:

In the connection string, it has the line initial catalog=MyProgramDB. However I'd like unit tests to use initial catalog=MyIntegrationTestingDB instead.

I tried creating a separate configuration for testing I can switch to, but I can't change the testing projects to any configuration except Debug or Release.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You didn't specify any code, so I will give you an example of how to initialize it with SQL Server and EF.

In your project Startup, you will need to inject the connection string.

It might be something like this:

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<DbContext>(options =>
        options.UseSqlServer(Configuration.GetConnectionString("<Name1>"));
}

The <Name1> will be the connection string that you want for the integration tests. In another project, you might use <Name2>.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda