Class TestResources

java.lang.Object
org.junit.rules.TestWatcher
org.apache.maven.plugin.testing.resources.TestResources
All Implemented Interfaces:
org.junit.rules.TestRule

public class TestResources extends org.junit.rules.TestWatcher
Junit4 test Rule to extract and assert test resources.
Since:
3.1.0
  • Constructor Details

    • TestResources

      public TestResources()
    • TestResources

      public TestResources(String projectsDir, String workDir)
  • Method Details

    • starting

      protected void starting(org.junit.runner.Description d)
      Overrides:
      starting in class org.junit.rules.TestWatcher
    • getBasedir

      public File getBasedir(String project) throws IOException
      Creates new clean copy of test project directory structure. The copy is named after both the test being executed and test project name, which allows the same test project can be used by multiple tests and by different instances of the same parametrized tests.

      TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters

      Throws:
      IOException
    • cp

      public static void cp(File basedir, String from, String to) throws IOException
      Throws:
      IOException
    • assertFileContents

      public static void assertFileContents(File basedir, String expectedPath, String actualPath) throws IOException
      Throws:
      IOException
    • assertDirectoryContents

      public static void assertDirectoryContents(File dir, String... expectedPaths)
    • touch

      public static void touch(File basedir, String path) throws InterruptedException
      Throws:
      InterruptedException
    • touch

      public static void touch(File file) throws InterruptedException
      Throws:
      InterruptedException
    • rm

      public static void rm(File basedir, String path)
    • create

      public static void create(File basedir, String... paths) throws IOException
      Throws:
      IOException
      Since:
      3.2.0