用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/googleapis/google-cloud-dart --skill google-cloud-location-tests命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | google-cloud-location-tests |
| description | Use this skill when writing tests for code that uses package:google_cloud_location |
Most unit tests should use fakes instead of making network requests to Google services.
Locations can be tested by injecting the
fake FakeLocations.Import the fakes from the testing library:
import 'package:google_cloud_location/testing.dart';
You can inject behavior by passing optional function callbacks to the fake's
constructor. Methods that are not provided will throw an UnsupportedError.
import 'package:google_cloud_location/location.dart';
import 'package:google_cloud_location/testing.dart';
final fake = FakeLocations(
getLocation: (request) async {
// Assert request contents here if needed.
return Location();
},
);
For more complex test setups or shared states, you can subclass the fake and
override its methods. Methods that are not overridden will throw an
UnsupportedError.
import 'package:google_cloud_location/location.dart';
import 'package:google_cloud_location/testing.dart';
final class MyFakeLocations extends FakeLocations {
@override
Future<Location> getLocation(
GetLocationRequest request,
) async {
// Assert request contents here if needed.
return Location();
}
}
import 'package:google_cloud_location/location.dart';
import 'package:google_cloud_location/testing.dart';
import 'package:test/test.dart';
Future<void> functionUnderTest(Locations service) async {
// Application logic here.
await service.getLocation(GetLocationRequest());
// More application logic here.
}
void main() {
test('test', () async {
final fake = FakeLocations(
getLocation: (request) async {
// Assert request contents here.
return Location();
},
);
// Instead of verifying that `functionUnderTest` completes, you should verify
// the relevant properties of the result.
await expectLater(functionUnderTest(fake), completes);
});
}