Deleting File and Directory in JUnit

前端 未结 4 1260
执笔经年
执笔经年 2021-02-09 08:20

I\'m writing a test for a method that creates a file in a directory. Here\'s what my JUnit test looks like:

  @Before
  public void setUp(){
      objectUnderTes         


        
4条回答
  •  我在风中等你
    2021-02-09 08:26

    I think the best approche is te delete after JVM exit :

    Path tmp = Files.createTempDirectory(null);
    tmp.toFile().deleteOnExit();
    

提交回复
热议问题