Does the unit test setUp/tearDown work in asynchronous testing?
-
11-12-2019 - |
Question
I was trying to work with it today in a scenario similar to this:
group('some group', (){
//prints
setUp(() => print('set up'));
test('some test', (){
window.requestLayoutFrame(
expectAsync0((){
Expect.isTrue(true);
})
);
});
//doesn't print
tearDown(() => print('tear down'));
});
In this example, the tearDown callback does not seem to be called.
When I place the tearDown() function before the unit test, then it does get called, but the output sequence is not what I would expect:
group('some group', (){
setUp(() => print('set up'));
tearDown(() => print('tear down'));
test('some test', (){
window.requestLayoutFrame(expectAsync0((){
print('in unit test');
Expect.isTrue(true);
}));
});
});
Yields:
set up
tear down
in unit test
PASS: some group some test
Shouldn't the unit test output before the tear down?
SDK build 9881
Solution
Bug. Resolved: http://www.dartbug.com/4284
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow