java.lang.Object
org.junit.platform.engine.support.descriptor.FileSource
All Implemented Interfaces:
Serializable, FileSystemSource, UriSource, TestSource

@API(status=STABLE, since="1.0") public class FileSource extends Object implements FileSystemSource
File based TestSource with an optional position.
Since:
1.0
See Also:
  • Method Details

    • from

      public static FileSource from(File file)
      Create a new FileSource using the supplied file.
      Parameters:
      file - the source file; must not be null
    • from

      public static FileSource from(File file, FilePosition filePosition)
      Create a new FileSource using the supplied file and filePosition.
      Parameters:
      file - the source file; must not be null
      filePosition - the position in the source file; may be null
      See Also:
    • getUri

      public final URI getUri()
      Get the URI for the source file.
      Specified by:
      getUri in interface UriSource
      Returns:
      the source URI; never null
    • getFile

      public final File getFile()
      Get the source file.
      Specified by:
      getFile in interface FileSystemSource
      Returns:
      the source file; never null
    • getPosition

      public final Optional<FilePosition> getPosition()
      Get the FilePosition, if available.
    • withPosition

      @API(status=EXPERIMENTAL, since="1.14") public FileSource withPosition(FilePosition filePosition)
      Returns a FileSource based on this instance but with the supplied FilePosition.

      If the supplied FilePosition equals the existing one, this method returns this. Otherwise, a new instance is created and returned.

      Calling this method rather than creating a new FileSource via from(File, FilePosition) avoids the overhead of redundant canonical path resolution.

      Parameters:
      filePosition - the position in the source file; may be null
      Returns:
      a FileSource based on this instance but with the supplied FilePosition
      Since:
      1.14
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object