Since dart test is parallel, I have encountered a problem that two more classes used same folder can't be deleted properly.
Let's see a folder structure:
Utility
- a_utility
- b_utility
Because Utility
might be empty, AUtilityClasss
will auto create Utility
and sub-direcoty a_utility
, and will be cleanup in teardown()
. Hence, I remove Utility
in teardown()
to be sure that next test will not be dependency with previous.
But dart test is parallel by default, If there is two class(BUtilityClasss
, CUtilityClasss
, ...) that rely on same directory, teardown()
may cause the error (Error: Can't delete because of in used
, or Already Deleted
) and might also affect tests in other b_utiliy_test.dart
to fail. The current workaround I tried to prevent this situation is to assign -j1
argument, and there is no two test in parallel, so It will be safe.
Therefore, It cames to two question.
- How to test that two classes use same directory?
- Reconstruct the classes in one class to fit the test?
I can't find any discussion anywhere, any information is appreciated!
Aucun commentaire:
Enregistrer un commentaire