Is there a "correct" folder to put test assets in the dart?

I have a simple dart class that I am trying to test.
To test it, I need to open a txt file, pass the content to an instance of the class, and check if the output is correct.

Where to place this txt file? The txt file is useless outside of testing.

Also, related, how can I use its directory consistently? I tried to put it in a test folder, but the problem is:

System.currentDirectory

      

Returns a different directory if I run the test itself or a script that calls all the other test dart files in one go

+3


source to share


1 answer


I check to see if System.currentDirectory is the directory containing the file pubspec.yaml

, unless I move the current directory up until I find the directory containing the file pubpsec.yaml

, then continue with the test code.



+2


source







All Articles