MaarkssDN/Birthub-360 / .agents/skills/azure-functions-tests
azure-functions-tests
VerifiedUse when Azure Functions need testing before deploy: running them locally with Core Tools v4 and Azurite, unit tests for .NET isolated, Node v4 and Python v2 handlers, HTTP, queue and timer triggers, admin-endpoint calls and binding checks in local.settings.json.
| File | Kind | Size |
|---|---|---|
| .tessl-plugin/plugin.json | config | 400 B |
| SKILL.md | skill md | 8.0 KB |
| references/local-setup.md | markdown | 3.1 KB |
| references/triggering-functions.md | markdown | 1.9 KB |
| references/unit-testing-handlers.md | markdown | 3.1 KB |
references/unit-testing-handlers.md
View on GitHub# Unit-testing handlers
Testing handler code directly avoids the overhead of a running host. The
approach differs by language. Companion to the `azure-functions-tests` skill.
## .NET isolated worker model
The .NET isolated worker model runs function code in a separate worker
process from the Functions host, per
[learn.microsoft.com/azure/azure-functions/dotnet-isolated-in-process-differences](https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-in-process-differences).
The core packages are `Microsoft.Azure.Functions.Worker` and
`Microsoft.Azure.Functions.Worker.Sdk`. HTTP triggers use
`HttpRequestData` / `HttpResponseData` (not `HttpRequest`/`IActionResult`)
unless ASP.NET Core integration is enabled.
Because handler classes can use dependency injection, extract service
dependencies behind interfaces and substitute test doubles. The
`FunctionContext` can be mocked with any standard mock library.
```csharp
// Handler under test
public class HttpExample
{
[Function("HttpExample")]
public HttpResponseData Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post")] HttpRequestData req,
FunctionContext context)
{
var response = req.CreateResponse(HttpStatusCode.OK);
response.WriteString("Hello from Azure Functions");
return response;
}
}
// xUnit test - construct HttpRequestData via a mock FunctionContext
// (use Moq, NSubstitute, or similar for FunctionContext and HttpRequestData)
[Fact]
public async Task Run_ReturnsOk()
{
var context = new Mock<FunctionContext>();
var request = CreateMockHttpRequest(context.Object, HttpMethod.Get);
var function = new HttpExample();
var response = function.Run(request, context.Object);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
}
```
## Node.js (v4 programming model)
```js
// handler.js
const { app } = require('@azure/functions');
app.http('HttpExample', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
const name = request.query.get('name') || 'World';
return { body: `Hello, ${name}!` };
},
});
// handler.test.js (Jest)
const { handler } = require('./handler');
test('returns greeting', async () => {
const req = { query: new URLSearchParams('name=Test'), text: async () => '' };
const ctx = { log: jest.fn() };
const res = await handler(req, ctx);
expect(res.body).toBe('Hello, Test!');
});
```
## Python (v2 programming model)
```python
# function_app.py
import azure.functions as func
app = func.FunctionApp()
@app.route(route="HttpExample")
def http_example(req: func.HttpRequest) -> func.HttpResponse:
name = req.params.get('name', 'World')
return func.HttpResponse(f"Hello, {name}!")
# test_function_app.py (pytest)
import azure.functions as func
from function_app import http_example
def test_http_example():
req = func.HttpRequest(
method='GET',
url='/api/HttpExample',
params={'name': 'Test'},
body=b''
)
resp = http_example(req)
assert resp.status_code == 200
assert 'Test' in resp.get_body().decode()
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |