Closed heitor481 closed 4 years ago
@heitor481 There isn't anything like Nancy.Browsr in Carter. AspNet has a TestServer which you can use, https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-2.2.
I have a couple of examples you can look at here, https://github.com/ritasker/CarterDemos/tree/master/SampleTests
I understood a few things that you've done on the project for testing. But, with TestServer I'm basically creating the same server that I am using, so, if I have multiple dependencies on my project, I will have to add all of that on the creation of the test host, right? Please, correct me if I am wrong
I'm asking that because, with nancy browser (I know carter doesn't have that), I can only create a specific instance of a particular module that I have. Following your example, I will have to create a host of my entire application?
var client = new TestServer(new WebHostBuilder() .ConfigureServices(s => { s.AddSingleton(actorProvider); s.AddCarter(); }) .Configure(app => { app.UseCarter(); }) ).CreateClient();
Is that right?
That is correct however UseCarter has an overload to choose which modules to instantiate
On Sat, 14 Sep 2019 at 23:20, Heitor Ribeiro de Souza < notifications@github.com> wrote:
I understood a few things that you've done on the project for testing. But, with TestServer I'm basically creating the same server that I am using, so, if I have multiple dependencies on my project, I will have to add all of that on the creation of the test host, right? Please, correct me if I am wrong
I'm asking that because, with nancy browser (I know carter doesn't have that), I can only create a specific instance of a particular module that I have. Following your example, I will have to create a host of my entire application?
var client = new TestServer(new WebHostBuilder() .ConfigureServices(s => { s.AddSingleton(actorProvider); s.AddCarter(); }) .Configure(app => { app.UseCarter(); }) ).CreateClient();
Is that right?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/CarterCommunity/Carter/issues/202?email_source=notifications&email_token=AAAZVJUPMPIKMOMSSU4MDSDQJVPSNA5CNFSM4IWK2LW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6XFFFQ#issuecomment-531518102, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAZVJUJXA74SBIJMWD75MDQJVPSNANCNFSM4IWK2LWQ .
Hi All,
When using the examples given above, I get this error :
Result Message:
System.Reflection.ReflectionTypeLoadException : Unable to load one or more of the requested types.
Could not load file or assembly 'Microsoft.Net.Http.Headers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.
My app is a NetCore 2.1 using Carter Framework 3.10. I have installed TestHost version 2.1 as well.
Has anyone a clue what this error is about?
I´m closing this issue here. The explanation was sufficient for me to make the tests needed on the project I am. Thanks a lot
Hey guys, hows it going? I started developing an application based on Microservices using Carter. And, I remember that with Nancy, we had a class to make unit tests using. Including a namespace called Nancy.Browser.
My question is: do we have something familiar with carter? If not, how it would be a best practice to test the modules that I am going to create?