netlens_test 1.1.0
netlens_test: ^1.1.0 copied to clipboard
Test matchers and mocks for writing and testing adapters of the NetLens in-app HTTP inspector.
NetLens Test example #
Mock the NetLens core and check the calls that your adapter adds to it.
import 'package:mocktail/mocktail.dart';
import 'package:netlens/core/netlens_core.dart';
import 'package:netlens/model/netlens_http_call.dart';
import 'package:netlens_test/netlens_test.dart';
import 'package:test/test.dart';
void main() {
late NetLensCore netLensCore;
setUp(() {
registerFallbackValue(NetLensHttpCall(0));
netLensCore = NetLensCoreMock();
when(() => netLensCore.addCall(any())).thenAnswer((_) {});
});
test('adds the call to NetLens', () {
// Make your adapter catch a GET request with netLensCore injected.
verify(
() => netLensCore.addCall(
any(that: buildCallMatcher(checkTime: true, method: 'GET')),
),
);
});
}
The adapter tests in packages use these matchers, for example netlens_http.