Best practices for file system dependencies in unit/integration tests

Posted by Olvagor on Stack Overflow See other posts from Stack Overflow or by Olvagor
Published on 2008-12-18T10:07:08Z Indexed on 2010/05/11 19:14 UTC
Read the original article Hit count: 390

I just started writing tests for a lot of code. There's a bunch of classes with dependencies to the file system, that is they read CSV files, read/write configuration files and so on.

Currently the test files are stored in the test directory of the project (it's a Maven2 project) but for several reasons this directory doesn't always exist, so the tests fail.

Do you know best practices for coping with file system dependencies in unit/integration tests?

Edit: I'm not searching an answer for that specific problem I described above. That was just an example. I'd prefer general recommendations how to handle dependencies to the file system/databases etc.

© Stack Overflow or respective owner

Related posts about unit-testing

Related posts about filesystem