RestCode / WebApiProxy

MIT License
199 stars 91 forks source link

Create unit/integration tests #82

Open onionhammer opened 8 years ago

onionhammer commented 8 years ago

We need some unit tests!

What we need most (imo) is automatic testing of code generation, ensuring it succeeds and is able to perform web api requests against a test service.

faniereynders commented 8 years ago

You are absolutely right @onionhammer.

In principle, generation tests don't need to connect to an actual service, as it only requires the metadata response which could be mocked, making verifying the results more accurate.

faniereynders commented 8 years ago

Unless we really need a set of complete end to end integration tests, if it will add any value

onionhammer commented 8 years ago

I've had some success hosting webapis in-proc (started by the test), not that much harder to do, then we actually exercise the httpclient.

faniereynders commented 8 years ago

Interesting. @onionhammer care to share an example of how you used it?

onionhammer commented 8 years ago

in a base test, you basically instantiate an HttpServer object (new HttpServer(config)).

I can dig up the code, but it's similar to this: http://blogs.msdn.com/b/youssefm/archive/2013/01/28/writing-tests-for-an-asp-net-webapi-service.aspx

faniereynders commented 8 years ago

What about testing the JavaScript client?

onionhammer commented 8 years ago

I've not done much JS unit testing, there are some good options I'm sure, and it would be valuable, but you'll have to get someone else to answer that question :)