Azure / azure-functions-dotnet-worker

Azure Functions out-of-process .NET language worker
MIT License
432 stars 184 forks source link

Integration test: testing end to end in isolated worker process with mockable services dependencies #1322

Open minhquang opened 1 year ago

minhquang commented 1 year ago

Hi,

It tried the end to end tests and it is fantastic. In isolated worker process, it is possible to inject mock services dependencies ? The objective would be to simulate different functional scenario. My first thought was to construct the host in memory such as webjob based functions but my goal is to test the HTTP call to the function from end to end.

The isolated worker process is launched in an independant process. In the github project AzureFunction.TestHelpers of Manuel Riezebosch (https://github.com/riezebosch/AzureFunctions.TestHelpers), we can inject mock services in the host builder. Similarly I could create a custom function worker service in the current process, but it is not a real end to end test because the host runs in the current process.

Another way, would be to create dynamically the mock services dependencies in the current process and before to start the isolated work process to test. I could configure the mock service urls in a setting file.

Am I wrong or is it something that could interest many people ?

Best regards

bhugot commented 1 year ago

My PR #1303 should allow this.

nulltoken commented 1 year ago

I'd be definitely interested in running end to end tests, leveraging stubbed http dependencies