Package org.testng
Class FileAssert
java.lang.Object
org.testng.FileAssert
Assertion tool for File centric assertions. Conceptually, this is an extension of
Assert
.
Presents assertion methods with a more natural parameter order. The order is always
actualValue, expectedValue [, message].- Since:
- 5.6
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Protect this constructor since it is a static only class. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
assertDirectory
(File tstvalue) static void
assertDirectory
(File tstvalue, String message) Asserts that atstvalue
is a proper directory.static void
assertFile
(File tstvalue) static void
assertFile
(File tstvalue, String message) Asserts that atstvalue
is a proper file.static void
assertLength
(File tstvalue, long expected) static void
assertLength
(File tstvalue, long expected, String message) Asserts that atstvalue
is a file of exactlyexpected
characters or a directory of exactlyexpected
entries.static void
assertMaxLength
(File tstvalue, long expected) static void
assertMaxLength
(File tstvalue, long expected, String message) Asserts that atstvalue
is a file of at mostexpected
characters or a directory of at mostexpected
entries.static void
assertMinLength
(File tstvalue, long expected) static void
assertMinLength
(File tstvalue, long expected, String message) Asserts that atstvalue
is a file of at leastexpected
characters or a directory of at leastexpected
entries.static void
assertReadable
(File tstvalue) static void
assertReadable
(File tstvalue, String message) Asserts that atstvalue
is readable.static void
assertReadWrite
(File tstvalue) static void
assertReadWrite
(File tstvalue, String message) Asserts that atstvalue
is readable and writeable.static void
assertWriteable
(File tstvalue) static void
assertWriteable
(File tstvalue, String message) Asserts that atstvalue
is writeable.static void
fail()
Fails a test with no message.static void
Fails a test with the given message.static void
Fails a test with the given message and wrapping the original exception.private static void
Formats failure for file assertions.private static void
private static String
fileAccess
(File path) String representation of read and write permissions ofpath
.private static String
String representation of what sort of filepath
is.private static String
-
Constructor Details
-
FileAssert
private FileAssert()Protect this constructor since it is a static only class.
-
-
Method Details
-
assertDirectory
Asserts that atstvalue
is a proper directory. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluatemessage
- the assertion error message
-
assertDirectory
-
assertFile
Asserts that atstvalue
is a proper file. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluatemessage
- the assertion error message
-
assertFile
- Parameters:
tstvalue
- The actual file- See Also:
-
assertLength
Asserts that atstvalue
is a file of exactlyexpected
characters or a directory of exactlyexpected
entries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluateexpected
- the expected valuemessage
- the assertion error message
-
assertLength
- Parameters:
tstvalue
- The actual fileexpected
- The expected length- See Also:
-
assertMinLength
Asserts that atstvalue
is a file of at leastexpected
characters or a directory of at leastexpected
entries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluateexpected
- the expected valuemessage
- the assertion error message
-
assertMinLength
- Parameters:
tstvalue
- The actual fileexpected
- The expected min length- See Also:
-
assertMaxLength
Asserts that atstvalue
is a file of at mostexpected
characters or a directory of at mostexpected
entries. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluateexpected
- The expected max lengthmessage
- the assertion error message
-
assertMaxLength
- Parameters:
tstvalue
- The actual fileexpected
- The expected length- See Also:
-
assertReadable
Asserts that atstvalue
is readable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluatemessage
- the assertion error message
-
assertReadable
- Parameters:
tstvalue
- The actual file- See Also:
-
assertWriteable
Asserts that atstvalue
is writeable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluatemessage
- the assertion error message
-
assertWriteable
- Parameters:
tstvalue
- The actual file- See Also:
-
assertReadWrite
Asserts that atstvalue
is readable and writeable. If it isn't, an AssertionError with the given message is thrown.- Parameters:
tstvalue
- the file to evaluatemessage
- the assertion error message
-
assertReadWrite
- Parameters:
tstvalue
- The actual file- See Also:
-
fail
Fails a test with the given message and wrapping the original exception.- Parameters:
message
- the assertion error messagerealCause
- the original exception
-
fail
Fails a test with the given message.- Parameters:
message
- the assertion error message
-
fail
public static void fail()Fails a test with no message. -
failFile
Formats failure for file assertions. -
failSecurity
private static void failSecurity(Exception e, File path, String actual, String expected, String message) - Parameters:
tstvalue
-string
-string2
-message
-
-
fileType
String representation of what sort of filepath
is. -
fileAccess
String representation of read and write permissions ofpath
. -
toString
-