Package net.kyori.mammoth.test
Class TestContext
java.lang.Object
net.kyori.mammoth.test.TestContext
Context information for individual tests.
Within this class, all input paths are for classpath resources relative to the current test class.
- Since:
- 1.1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoidassertOutputEquals(String resourceName, String fileName) Expect that the contents of the output filefileNameis equal to the contents of the resource at<testName>/out/<resourceName>.voidassertOutputEqualsLiteral(String destination, String text) Assert that the output atdestinationis equal to the literaltext.org.gradle.testkit.runner.BuildResultCreate and execute a new Gradle runner.voidCopy a resource from the<testName>/in/directory to the run directory with no changes.voidcopy a resource from the<testName>/in/directory to the run directory with the provided new name.The output directory for the Gradle build.readOutput(String fileName) Expect that a file is present in the output directory with the provided path.org.gradle.testkit.runner.GradleRunnerCreate a new Gradle runner.voidWrite literal text to a file in the run director with the provided new name.
-
Method Details
-
outputDirectory
The output directory for the Gradle build.- Returns:
- the output directory
- Since:
- 1.1.0
-
copyInput
Copy a resource from the<testName>/in/directory to the run directory with no changes.- Parameters:
name- the input relative to the test's directory- Throws:
IOException- if an error occurs writing the input file to disk- Since:
- 1.1.0
-
copyInput
copy a resource from the<testName>/in/directory to the run directory with the provided new name.- Parameters:
fromName- the name relative to the inputtoName- the name to use in the test's output directory- Throws:
IOException- if an error occurs writing the input file to disk- Since:
- 1.1.0
-
writeText
Write literal text to a file in the run director with the provided new name.- Parameters:
destination- The path to the location to write totext- the text to write- Throws:
IOException- if an error occurs writing the text- Since:
- 1.2.0
-
readOutput
Expect that a file is present in the output directory with the provided path.- Parameters:
fileName- the file name- Returns:
- the contents of the file as a string
- Throws:
IOException- if thrown while attempting to read the output file- Since:
- 1.1.0
-
assertOutputEqualsLiteral
Assert that the output atdestinationis equal to the literaltext.- Parameters:
destination- the output file to checktext- the expected text- Throws:
IOException- if an error occurs reading the text- Since:
- 1.2.0
-
assertOutputEquals
Expect that the contents of the output filefileNameis equal to the contents of the resource at<testName>/out/<resourceName>.- Parameters:
resourceName- the name of the expected resourcefileName- the name of the actual output file- Throws:
IOException- if failed to read one of the files- Since:
- 1.1.0
-
runner
Create a new Gradle runner.- Parameters:
extraArgs- extra arguments to provide- Returns:
- the new runner
- Since:
- 1.1.0
-
build
Create and execute a new Gradle runner.- Parameters:
extraArgs- the extra arguments to provide- Returns:
- the result of an executed build
- Since:
- 1.1.0
-