Package it.tidalwave.util.test
Class BaseTestHelper
java.lang.Object
it.tidalwave.util.test.BaseTestHelper
- Direct Known Subclasses:
SpringTestHelper
A facility that provides some common tasks for testing, such as manipulating test files.
- Since:
- 3.2-ALPHA-18
- Author:
- Fabrizio Giudici
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
A manipulator of a pair of (actual file, expected file). -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionreadStringFromResource
(String resourceName) Reads the content from the resource file as a single string.resourceFileFor
(String resourceName) Returns aPath
for a resource file.testResourceFor
(String resourceName) Create aBaseTestHelper.TestResource
for the given name.
-
Field Details
-
test
-
-
Constructor Details
-
BaseTestHelper
public BaseTestHelper()
-
-
Method Details
-
resourceFileFor
Returns aPath
for a resource file. The resource should be placed undersrc/test/resources/test-class-simple-name/test-resources/resource-name
. Note that the file actually loaded is the one undertarget/test-classes
copied there (and eventually filtered) by Maven.- Parameters:
resourceName
- the resource name- Returns:
- the
Path
-
readStringFromResource
Reads the content from the resource file as a single string. SeeresourceFileFor(String)
for further info.- Parameters:
resourceName
- the resource name- Returns:
- the string
- Throws:
IOException
- in case of error
-
testResourceFor
@Nonnull public BaseTestHelper.TestResource testResourceFor(@Nonnull String resourceName) throws IOException Create aBaseTestHelper.TestResource
for the given name. The actual file will be created undertarget/test-artifacts/test-class-simple-name/resourceName
. The expected file should be placed insrc/test/resources/test-class-simple-name/expected-results/resource-name
. Note that the file actually loaded is the one undertarget/test-classes
copied there (and eventually filtered) by Maven. Thetest-class-simple-name
is tried first with the current test, and then with its eventual super-classes; this allows to extend existing test suites. Note that if the resource files for a super class are not in the current project module, they should be explicitly copied here (for instance, by means of the Maven dependency plugin).- Parameters:
resourceName
- the name- Returns:
- the
TestResource
- Throws:
IOException
- in case of error
-