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
ConstructorsModifierConstructorDescriptionprivateProtect this constructor since it is a static only class. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertDirectory(File tstvalue) static voidassertDirectory(File tstvalue, String message) Asserts that atstvalueis a proper directory.static voidassertFile(File tstvalue) static voidassertFile(File tstvalue, String message) Asserts that atstvalueis a proper file.static voidassertLength(File tstvalue, long expected) static voidassertLength(File tstvalue, long expected, String message) Asserts that atstvalueis a file of exactlyexpectedcharacters or a directory of exactlyexpectedentries.static voidassertMaxLength(File tstvalue, long expected) static voidassertMaxLength(File tstvalue, long expected, String message) Asserts that atstvalueis a file of at mostexpectedcharacters or a directory of at mostexpectedentries.static voidassertMinLength(File tstvalue, long expected) static voidassertMinLength(File tstvalue, long expected, String message) Asserts that atstvalueis a file of at leastexpectedcharacters or a directory of at leastexpectedentries.static voidassertReadable(File tstvalue) static voidassertReadable(File tstvalue, String message) Asserts that atstvalueis readable.static voidassertReadWrite(File tstvalue) static voidassertReadWrite(File tstvalue, String message) Asserts that atstvalueis readable and writeable.static voidassertWriteable(File tstvalue) static voidassertWriteable(File tstvalue, String message) Asserts that atstvalueis writeable.static voidfail()Fails a test with no message.static voidFails a test with the given message.static voidFails a test with the given message and wrapping the original exception.private static voidFormats failure for file assertions.private static voidprivate static StringfileAccess(File path) String representation of read and write permissions ofpath.private static StringString representation of what sort of filepathis.private static String
-
Constructor Details
-
FileAssert
private FileAssert()Protect this constructor since it is a static only class.
-
-
Method Details
-
assertDirectory
Asserts that atstvalueis 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 atstvalueis 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 atstvalueis a file of exactlyexpectedcharacters or a directory of exactlyexpectedentries. 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 atstvalueis a file of at leastexpectedcharacters or a directory of at leastexpectedentries. 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 atstvalueis a file of at mostexpectedcharacters or a directory of at mostexpectedentries. 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 atstvalueis 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 atstvalueis 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 atstvalueis 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:
message-tstvalue-string-string2-
-
fileType
String representation of what sort of filepathis. -
fileAccess
String representation of read and write permissions ofpath. -
toString
-