MyTested.WebApi
MyTested.WebApi copied to clipboard
Make WithResponseTime more fluent
Currently the method can be called only after ShouldReturnHttpResponseMessage
@ivaylokenov : Thankq , But am trying to use it in my Integration Testing. I get errors. Can we achieve Integration testing from Remote server using this library?.
Example: My Web API is running in another server, I need to send request & get response from that server. Does this library supports it ?
@tdbgautham Can you please give me the integration test code and the errors you receive and I will take a look and fix it.
Also how do you start and setup the integration test code?
@tdbgautham I tested locally and it fails here too because currently the server is started in memory but it will be easy feature to add. Will update the library tomorrow.
@ivaylokenov Yes, i need to know . How to Start & Setup too . I used Global Configuration. If there is a sample webapi project & respective test case for that webapi will helpful. I have concerns on these -> How to start a Remote server, is there a sample ? -> What is Working(StartUp) ?
I cannot share my code has it owned by company. :( .
Most probably you are starting local server with your configuration. There is sample integration testing here, but the server is local: https://github.com/ivaylokenov/MyTested.WebApi/blob/master/samples/Source%20Control%20System%20API/Tests/SourceControlSystem.Api.Tests/IntegrationTests/CommitsIntegrationTests.cs
Will add remote server testing by providing only the base URL address. Should that be ok?
Yes.That will be helpful. An test case which connects to remote server and does api call and fr that what will be Response time.
-----Original Message----- From: "Ivaylo Kenov" [email protected] Sent: 04-12-2015 12:38 To: "ivaylokenov/MyTested.WebApi" [email protected] Cc: "tdbgautham" [email protected] Subject: Re: [MyTested.WebApi] Make WithResponseTime more fluent (#230)
Most probably you are starting local server with your configuration. There is sample integration testing here, but the server is local: https://github.com/ivaylokenov/MyTested.WebApi/blob/master/samples/Source%20Control%20System%20API/Tests/SourceControlSystem.Api.Tests/IntegrationTests/CommitsIntegrationTests.cs Will add remote server testing by providing only the base URL address. Should that be ok? — Reply to this email directly or view it on GitHub.
@tdbgautham Implemented in version 1.1.8. You can update your package. More information here: https://github.com/ivaylokenov/MyTested.WebApi/tree/master/documentation#remote-server
@ivaylokenov I am able to connect Remotely. But i am not able to provide handler to the remotely accessible server. Included changes for Handler for remoter server. Its working now. Thank you.
@ivaylokenov I have one concern on Dispose,. When we do Integration testing, we call many API based on scenario. When i tried that way, it disposes MyWebApi class for single API call. So again i need to do Set-Up. Why can't we dispose this link in server().STOP() . ?
@tdbgautham You should do it the following way:
// first run this
MyWebApi.Server().IsLocatedAt("http://myremoteurl.com");
// then how many you want of these
MyWebApi
.Server()
.WorkingRemotely() // working remotely will use the globally set base address
.WithHttpRequestMessage(req => req.WithMethod(HttpMethod.Get))
.ShouldReturnHttpResponseMessage()
.WithStatusCode(HttpStatusCode.OK);
Any problems with that? What is your setup code? Can you give a sample or your usage?
@ivaylokenov tried as mentioned above, but i need to set Handler in Remote server for my request. I tried to set as GlobalClient in your library by including handler, but its getting disposed.
MyWebApi.Server().IsLocatedAt("http://localhost/", handler);
Tried this way. I am able to get Handler for 1st request, but second request again i need to set the handler. I dont know why.
@tdbgautham Will take a look. Can you give some sort of code sample what are you trying to do because I am kind of guessing your problem?
@ivaylokenov Ok. How can we set global handler for remote server integration testing ?
@tdbgautham Ususally you do not need to set the handler. Can you write a small code sample and add it to pastebin so that I can see what you are trying to accomplish and guide you to a solution?