What is the best approach for integration testing an Azure TimerTrigger Function?
I have an Azure Function that copies data from an Oracle table to Azure SQL table and sends an email via SendGrid. Here is the pseudo code:
public static void Run(TimerInfo myTimer, ILogger log)
{
Fecth_Data_From_Oracle_table()
Insert_Data_To_AzureSQL_table()
Send_StatusEmail_Via_SendGrid()
}
As seen the Function doesn't return anything, so how would I approach Integration Testing this function?
Do I modify the return type to something like Task<IActionResult>, but then I am modifying some already running code and returning some HTTP codes based on results from the methods?
Do I just call the timer trigger function from Visual Studio with the api key and HttpClient class f.x. GET https://myfunc01.azurewebsites.net/admin/functions/TimerTriggereFunc?code={key} and assert on its return value? (This requires that the Function returns something.)
Jeff Holan has examples of integration testing an Azure Function locally by using the System.Diagnostics.Process class to start and stop the .NET Core CLI (dotnet.exe), which in turn starts the Azure Functions host through the func.dll, but this seems overly complicated. Is it a wrong approach to integration test the Azure Function where it is hosted in Azure or is it a must to test it locally?
I can't seem to find clear guidelines around this.
