Class Sample

java.lang.Object
org.gradle.exemplar.test.rule.Sample
All Implemented Interfaces:
org.junit.rules.TestRule

public class Sample extends Object implements org.junit.rules.TestRule
A JUnit rule which copies a sample into the test directory before the test executes.

Looks for a UsesSample annotation on the test method to determine which sample the test requires. If not found, uses the default sample provided in the constructor.

  • Method Details

    • from

      public static Sample from(String sourceBaseDirPath)
    • from

      public static Sample from(Sample.SourceSampleDirSupplier sourceSampleDirSupplier)
    • into

      @Deprecated public Sample into(org.junit.rules.TemporaryFolder temporaryFolder)
      Copy the samples into the supplied TemporaryFolder.
    • intoTemporaryFolder

      public Sample intoTemporaryFolder()
      Copy the samples into a temporary folder that is attempted to be deleted afterwards.
    • intoTemporaryFolder

      public Sample intoTemporaryFolder(File parentFolder)
      Copy the samples into a temporary folder that is attempted to be deleted afterwards.
      Parameters:
      parentFolder - The parent folder of the created temporary folder
    • into

      public Sample into(Sample.TargetBaseDirSupplier targetBaseDirSupplier)
      Copy the samples into a folder returned by the supplied Sample.TargetBaseDirSupplier.
      See Also:
    • withDefaultSample

      public Sample withDefaultSample(String name)
    • 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
    • getDir

      public File getDir()