|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.scijava.test.TestUtils
public class TestUtils
A bunch of helpful functions for unit tests.
Constructor Summary | |
---|---|
TestUtils()
|
Method Summary | |
---|---|
static File |
createTemporaryDirectory(String prefix)
Makes a temporary directory for use with unit tests. |
static File |
createTemporaryDirectory(String prefix,
Class<?> forClass)
Makes a temporary directory for use with unit tests. |
static File |
createTemporaryDirectory(String prefix,
Class<?> forClass,
String suffix)
Makes a temporary directory for use with unit tests. |
static Class<?> |
getCallingClass(Class<?> excluding)
Returns the class of the caller (excluding the specified class). |
static Map.Entry<Class<?>,String> |
getCallingCodeLocation(Class<?> excluding)
Returns the class and the method/line number of the caller (excluding the specified class). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TestUtils()
Method Detail |
---|
public static File createTemporaryDirectory(String prefix) throws IOException
When the unit test runs in a Maven context, the temporary directory will be created in the target/ directory corresponding to the calling class instead of /tmp/.
prefix
- the prefix for the directory's name
IOException
public static File createTemporaryDirectory(String prefix, Class<?> forClass) throws IOException
When the unit test runs in a Maven context, the temporary directory will be created in the corresponding target/ directory instead of /tmp/.
prefix
- the prefix for the directory's nameforClass
- the class for context (to determine whether there's a
target/ directory)
IOException
public static File createTemporaryDirectory(String prefix, Class<?> forClass, String suffix) throws IOException
When the unit test runs in a Maven context, the temporary directory will be created in the corresponding target/ directory instead of /tmp/.
prefix
- the prefix for the directory's nameforClass
- the class for context (to determine whether there's a
target/ directory)suffix
- the suffix for the directory's name
IOException
public static Class<?> getCallingClass(Class<?> excluding)
Sometimes it is convenient to determine the caller's context, e.g. to determine whether running in a maven-surefire-plugin context (in which case the location of the caller's class would end in target/test-classes/).
excluding
- the class to exclude (or null)
public static Map.Entry<Class<?>,String> getCallingCodeLocation(Class<?> excluding)
Sometimes it is convenient to determine the caller's context, e.g. to determine whether running in a maven-surefire-plugin context (in which case the location of the caller's class would end in target/test-classes/).
excluding
- the class to exclude (or null)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |