The following code tests the received datas on a server sent by a client.
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:unittest/unittest.dart';
main() {
ServerSocket ss;
setUp(() => ServerSocket.bind('localhost', 9876).then((e) => ss = e));
tearDown(() => ss.close());
test('test 1', () {
final line = new Completer<String>();
ss.listen((s) => s.map(UTF8.decode).listen((s) => line.complete(s)));
Socket.connect(ss.address, ss.port)
.then((s) {
s.write('test');
return s.close();
})
.then((_) => line.future)
.then(expectAsync((s) => expect(s, equals('test'))));
});
}
This test displays:
unittest-suite-wait-for-done
PASS: test 1
All 1 tests passed.
unittest-suite-success
However, the process doesn't stop.
- Why the process is still running even with the
ss.close()
ands.close()
? - How to find what makes the process stay alive? Does Observatory provide something to debug that ?