Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the best way to check in a unit-test if all randomaccessfile objects are closed properly? #191

Open
jeduden opened this issue Oct 14, 2021 · 0 comments

Comments

@jeduden
Copy link

jeduden commented Oct 14, 2021

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();
   return await 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant