Open jaredcnance opened 7 years ago
I would start by looking at our own e2e tests. For example we have this test fixture that should get you started.
If you end up building a test harness along the lines of what you outlined above that could be pretty useful in general, you should let us know.
Reopen this if you're still blocked.
It looks like that fixture is dependent upon System.Web.Http
, will that be changing with the movement to dotnet core?
Good question. I'm not sure what test fixture updates are planned, @fabiocav should be able to answer.
I don't want to try and craft a solution based on volatile infrastructure, but this is something that is sorely needed, especially when the risk of runtime errors is so high because of https://github.com/Azure/azure-webjobs-sdk-script/issues/992
It looks like JobHost may be the thing I'm looking for in the future?
But then there is also this FunctionsLocalServer which seems to just start a new AspNetCore web host by spawning a new process to run the host via StartHostAction.
Can anyone provide me with the current design/direction so I don't do work that boxes me into a corner in future versions? Between this repository and the azure-functions-cli repo, I'm thoroughly confused as to how the runtime actually works.
Can we re-open this issue? I'm not sure why it is closed. I don't think a proper solution has been provided nor do I have enough information to produce one.
I'm also facing the same challenge and agree with @jaredcnance - it would be great if there was some guidance here.
Spent some time this weekend playing with this during some travel. I shared my project here. As @paulbatum suggested it follows the same patterns used by the azure functions host project. It's a proof of concept but does allow me to execute the Azure Functions Host inside the test suite and not as an external executable. Has some kinks (wasn't able to ever get the breakpoints inside the function to fire when debugging) but should enable you to verify assembly loading as part of a test
+1
Curious if @fabiocav has anything he is able to share about a proper test fixture for function apps.
Checkout my solution: https://github.com/riezebosch/AzureFunctions.TestHelpers. It indeed uses the JobsHost from the SDK with some helper functions & classes aside to invoke http-triggered functions and wait for orchestration completion.
@riezebosch this is awesome! So glad someone took some time to look into this as my sample is very stale at this point. Will check this out
3.5 years on, is there any official advice on how to achieve this?
@matt-lethargic there have been recommendations from @jeffhollan and @paulbatum on this issue. Aside from that, that has been no other work done.
Please do understand that, though the original question/request was made a while ago, there have been no commitments to bring anything beyond what we've been able to share. This is not something that have seen enough demand to be prioritized over other items with higher impact.
We decided to keep this open, as the idea is good and valid, but I want to make sure that wasn't sending the wrong message. In the meantime, I'll add a help wanted
label to this as it would be a good opportunity for community engagement.
I am looking for guidelines and tips to write in-memory integration tests for a set of V4 Azure Functions (.Net Core 6 & C#) in isolation mode (out-of-process). Is there any relevant content/sample/article available?
@fabiocav , please tag this as feature
.
Being able to run integration tests locally is the basic requirement for modern frameworks/infrastructures.
Moreover, as a customer, I can say that testability
plays the key role when choosing technology stack for solution.
the idea is good and valid
The idea of DI with test support is rather pretty old and globally adopted than good and valid
, the official documentation with static function testing looks like disparage to the intelligence of Azure developers.
This is not something that have seen enough demand to be prioritized over other items with higher impact.
I think I'm not the only one who can't imagine writing code without being able to run unit/integration test locally with debugger support. I think no need to measure the demand for such capability
@milad-ghafoori what do you mean by out-of-process? If you look at my repository I've done some examples and included some helper methods but other than that it just uses the bits and pieces to set up a jobhost from the official SDK. For me that gives me just enough guarantee that my functions will eventually run appropriately in their designated runtime.
I've done an online session on how I do that: https://youtu.be/o1EqbeVF1EA?t=1501
The problem
I would like to be able to run integration tests using the Azure Function runtime.
Workaround
I can use a
FunctionRunner
like this to fire up the runtime and then validate the results after some specified timeout.There are several problems:
while(Debugger.IsAttached == false) {/*...*/}
hack.func.exe
to be installed on the testing server in a hardcoded locationDesired Solution
It would be great if we had a solution similar to AspNetCore that might look something like:
A few things I would like to see included:
If the tools to do this already exist (within this project or any other), please let me know.