Integration tests after switching to ASP.NET Core RC2

In my integration tests, I use the TestServer class to work with a test server instance for my integration tests. In RC1, I used it using the following code:

 var server = new TestServer(TestServer.CreateBuilder().UseStartup<Startup>()); 

In RC2, TestServer.CreateBuilder () has been removed. So I tried to create a new TestServer using the following code:

 var server = new TestServer(new WebHostBuilder().UseStartup<Startup>()); 

The problem I ran into is that after RC2, the runtime cannot resolve dependencies for DI, so it throws exceptions from the Configure method for the Startup class. However, the system starts if I run a real server (and not a test project). The exception is the following:

  System.Exception : Could not resolve a service of type 'ShikashiBot.IShikashiBotManager' for the parameter 'botManager' of method 'Configure' on type 'ShikashiBot.Startup'. 

I am currently using the following package for a test host: Microsoft.AspNetCore.TestHost": "1.0.0-rc2-final

+7
c # integration-testing asp.net-core
source share
1 answer

I needed to make some changes to make your repo work:

  • I had to rename appsettings.sample.json to appsettings.json , I think this only happens because it is not in the original control.
  • I had to add "buildOptions": { "copyToOutput": [ "appsettings.json" ] } to the project.json of the IntegrationTests project.
  • To change the Verbose log level to Debug in appsettings.json .

But after that, the EndPointsRequiresAuthorization integration EndPointsRequiresAuthorization goes through dependency injection, and for me this is a failure with an exception in ShikashiBotManager , I think because I do not have Postgre DB settings.
For you, this fails already, because it cannot resolve the IShikashiBotManager interface, right?

Is it possible to perform a complete cleanup of the local repository using git clean -xfd ( NOTE : your local changes will not be deleted), rebuild and try again?

+7
source share

All Articles