简体   繁体   中英

Integration testing Azure function app that connect to Service Bus queue

I have developed a function app that is triggered by a Http request, and peeks a respective queue (connects to it by a connection string) on the Service Bus for messages with a specific parameter value, and delete them.

In addition to regular testing when developing, it would be great to create integration tests and run them in a CI/CD process, but I don't know how to mock the queue that the function app connects too (creating a test queue that resides on the Service bus only to be used for test-purposes is not an option). Does anyone have any idea how to proceed?

One of the options would be to provision a temporary Azure Service Bus namespace in the beginning prior to executing an integration test suite and tearing it down at the end. The namespace would be a standard tier namespace. Provisioning and tearing down could be done with either ARM template, PowerShell, or Azure CLI.

An additional benefit of this approach is security. A namespace per test suite run will ensure that PR from external contributors can be safely executed, in case your repository is public.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM