Class JUnitTempFolder

java.lang.Object
org.junit.rules.ExternalResource
org.sonar.api.impl.utils.JUnitTempFolder
All Implemented Interfaces:
org.junit.rules.TestRule, org.sonar.api.utils.TempFolder

public class JUnitTempFolder extends org.junit.rules.ExternalResource implements org.sonar.api.utils.TempFolder
Implementation of TempFolder to be used only in JUnit tests. It wraps TemporaryFolder.
Example:
 public class MyTest {
   @@org.junit.Rule
   public JUnitTempFolder temp = new JUnitTempFolder();

   @@org.junit.Test
   public void myTest() throws Exception {
     File dir = temp.newDir();
     // ...
   }
 }
 
Since:
5.1
  • Constructor Details

    • JUnitTempFolder

      public JUnitTempFolder()
  • Method Details

    • apply

      public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
      Specified by:
      apply in interface org.junit.rules.TestRule
      Overrides:
      apply in class org.junit.rules.ExternalResource
    • before

      protected void before() throws Throwable
      Overrides:
      before in class org.junit.rules.ExternalResource
      Throws:
      Throwable
    • after

      protected void after()
      Overrides:
      after in class org.junit.rules.ExternalResource
    • newDir

      public File newDir()
      Specified by:
      newDir in interface org.sonar.api.utils.TempFolder
    • newDir

      public File newDir(String name)
      Specified by:
      newDir in interface org.sonar.api.utils.TempFolder
    • newFile

      public File newFile()
      Specified by:
      newFile in interface org.sonar.api.utils.TempFolder
    • newFile

      public File newFile(@Nullable String prefix, @Nullable String suffix)
      Specified by:
      newFile in interface org.sonar.api.utils.TempFolder
    • getRoot

      public File getRoot()