You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am wondering how I can best write test code to ensure the code under test properly closes open files. For example:
Future<int> readAbit(File f) async {
final raf =await f.open();
returnawait raf.readByte(); /// should have wrapped this in a try-finally
}
The file f is opened inside readAbit. A unit-test would not have access to the raf variable to check if it is closed.
Usually returning rafdoesnt make much sense. It would be much more helpful to be able to inspect f and check for any dangling RandomAccessFile objects.
The text was updated successfully, but these errors were encountered:
I am wondering how I can best write test code to ensure the code under test properly closes open files. For example:
The file
f
is opened insidereadAbit
. A unit-test would not have access to theraf
variable to check if it is closed.Usually returning
raf
doesnt make much sense. It would be much more helpful to be able to inspectf
and check for any danglingRandomAccessFile
objects.The text was updated successfully, but these errors were encountered: