我试图在 Flutter 中进行单元测试。
在pubspec.yaml
依赖项中包括:
test: any
运行flutter analyze
不显示任何警告。
在我的项目中创建了一个unit_test.dart
下文件夹:test
import 'package:test/test.dart';
void main()
{
test('this is a test', (){
expect(42, equals(42));
//expect(42,42);
});
}
运行flutter test
显示以下错误:
➜ HelloFlutter flutter test test/unit_test.dart
00:00 +0: loading /home/tr/programs/HelloFlutter/test/unit_test.dart 00:00 +0 -1: loading /home/tr/programs/HelloFlutter/test/unit_test.dart 00:00 +0 -1: loading /home/tr/programs/HelloFlutter/test/unit_test.dart
Failed to load "/home/tr/programs/HelloFlutter/test/unit_test.dart": Failed assertion: boolean expression must not be null
package:test test
test/unit_test.dart 6:2 main
dart:async _StreamController.add
websocket_impl.dart 1111 _WebSocketImpl._WebSocketImpl._fromSocket.<fn>
dart:async _EventSinkWrapper.add
websocket_impl.dart 333 _WebSocketProtocolTransformer._messageFrameEnd
websocket_impl.dart 228 _WebSocketProtocolTransformer.add
00:00 +0 -1: Some tests failed.
有什么提示吗?