Parallel execution of tests

前端 未结 5 522
孤独总比滥情好
孤独总比滥情好 2021-01-01 12:20

I\'ve noticed that SBT is running my specs2 tests in parallel. This seems good, except one of my tests involves reading and writing from a file and hence fails unpredictabl

5条回答
  •  旧巷少年郎
    2021-01-01 12:38

    Fixed sequence of tests for suites can lead to interdependency of test cases and burden in maintenance.

    I would prefer to test without touching the file system (no matter either it is business logic or serialization code), or if it is inevitable (as for testing integration with file feeds) then would use creating temporary files:

    // Create temp file.
    File temp = File.createTempFile("pattern", ".suffix");
    // Delete temp file when program exits.
    temp.deleteOnExit();
    

提交回复
热议问题