Logic App Standard单元测试框架无法Mock外部API HTTP请求
我们正在使用Logic App Standard Unit Testing Framework,目前遇到一个关键问题:无法Mock对外部API的HTTP请求——无论怎么构建Mock规则,系统始终返回真实API的数据。
在测试场景中,我们能够正常Mock对本地Function App的操作请求,但针对外部API的HTTP操作,Mock完全不起作用。
我们已经逐一验证过:所有用于Mock匹配的参数均有效,且与实际HTTP操作的参数完全一致;同时也尝试了多种匹配方式,问题依然存在。
相关测试文件:
- Test.cs
- Parameters.json
- testConfiguration.json
- Tests.csproj
- workflow.json
示例返回数据:
{"users": [{"id": 1001101,"first_name": "Jack","last_name": "Wilson","email": "jwilson@email.com","telephone": "","timezone": "Pacific Time (US & Canada)","weekly_capacity": 144000,"has_access_to_all_future_projects": false,"is_contractor": true,"is_active": true,"calendar_integration_enabled": false,"calendar_integration_source": null,"created_at": "2024-11-05T21:18:55Z","updated_at": "2024-11-05T21:25:58Z","can_create_projects": false,"default_hourly_rate": 150,"cost_rate": null,"roles": ["Integration Developer"],"access_roles": ["member"],"permissions_claims": ["expenses:read:own","expenses:write:own","timers:read:own","timers:write:own"],"avatar_url": "https://f8df58sdf58sdf5.mocked.net/v2/default-avatars/d8D8.png"},{"id": 1001102,"first_name": "Sasha","last_name": "Miller","email": "s.miller@email.com","telephone": "","timezone": "Pacific Time (US & Canada)","weekly_capacity": 144000,"has_access_to_all_future_projects": false,"is_contractor": true,"is_active": true,"calendar_integration_enabled": false,"calendar_integration_source": null,"created_at": "2024-04-08T19:52:51Z","updated_at": "2024-05-30T07:48:13Z","can_create_projects": false,"default_hourly_rate": 0,"cost_rate": 0,"roles": ["Project Manager"],"access_roles": ["member"],"permissions_claims": ["expenses:read:own","expenses:write:own","timers:read:own","timers:write:own"],"avatar_url": "https://E8A58Df85fsdf8d.mocked.net/v2/default-avatars/8D58.png"},{"id": 1001103,"first_name": "Luke","last_name": "Walker","email": "lukewalker@email.com","telephone": "","timezone": "Pacific Time (US & Canada)","weekly_capacity": 144000,"has_access_to_all_future_projects": false,"is_contractor": true,"is_active": true,"calendar_integration_enabled": false,"calendar_integration_source": null,"created_at": "2024-04-08T19:52:51Z","updated_at": "2024-05-30T07:48:13Z","can_create_projects": false,"default_hourly_rate": 0,"cost_rate": 0,"roles": ["Integration Contractor"],"access_roles": ["member"],"permissions_claims": ["expenses:read:own","expenses:write:own","timers:read:own","timers:write:own"],"avatar_url": "https://8E5e357s2d12g45.mocked.net/v2/default-avatars/f85e.png"}],"per_page": 2000,"total_pages": 1,"total_entries": 12,"next_page": null,"previous_page": null,"page": 1,"links": {"first": "https://api.mockedharvestapp.com/v2/users?is_active=true&page=1&per_page=2000&ref=first","next": null,"previous": null,"last": "https://api.mockedharvestapp.com/v2/users?is_active=true&page=1&per_page=2000&ref=last"}}
内容的提问来源于stack exchange,提问作者Shane Lucyk

