Helper functions not registered
Hi @riezebosch ,
I'm trying to write some integration tests using your helpers however I'm facing issues with durable functions. This is how I creating my host:
_host = new HostBuilder()
.ConfigureWebJobs(builder => builder
.AddDurableTask()
.AddAzureStorageCoreServices()
.AddAzureStorageQueues()
.AddAzureStorageBlobs()
.UseWebJobsStartup(
typeof(FunctionsTestStartup),
new WebJobsBuilderContext()
{
ApplicationRootPath = Environment.CurrentDirectory,
EnvironmentName = "Test",
Configuration = inMemoryConfig
},
NullLoggerFactory.Instance))
.Build();
It's a reusable host in a XUnit fixture.
In my test class (using this fixture), I have the following code:
public Task InitializeAsync() =>
_host.Jobs
.Terminate()
.Purge();
It always fails on Terminate() extension method with the following error: System.InvalidOperationException : 'TerminateFunction' can't be invoked from Azure WebJobs SDK. Is it missing Azure WebJobs SDK attributes?
When stepping into it, I found out that AzureFunctions.TestHelpers functions are not listed in the context :
Only my project's functions are listed. I think that's why it's failing. Is there a way to load/include these functions ?
Normally it is enough to use something from the library for it to be loaded/discovered, and by invoking the Terminate() function should qualify. Otherwise you could explicitly load it by adding something like _ = typeof(TerminateFunction).FullName prior to setting op the job host.
Didn't work for me. I've managed to get them in the collection by loading the assembly before configuring the WebJobsHost but faced a lot of issues as described here : #10 So for the moment, I copied all your classes (except DummyHttpContext) in my test project and it works like a charm 😍
Thank you!
Please, checkout the update. I think it is resolved now by explicitly targetting net6.0 besides netstandard2.1.
I've just tested now and it's still doesn't work out of the box.
However, I've been able to make it work by using your workaround : _ = typeof(TerminateFunction).FullName
I managed to remove all classes that I copied previously 👍