Best practices for file system dependencies in unit/integration tests

前端 未结 5 641
星月不相逢
星月不相逢 2020-12-29 05:29

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

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 06:20

    Give the test files, both in and out, names that are structurally similar to the unit test name.

    In JUnit, for instance, I'd use:

    File reportFile = new File("tests/output/" + getClass().getSimpleName() + "/" + getName() + ".report.html");
    

提交回复
热议问题