asPath
Turns Expect<File>
into Expect<Path>
.
The transformation as such is not reflected in reporting. Use feature(File::toPath)
if you want to show the transformation in reporting.
Return
The newly created Expect for the transformed subject.
Since
0.9.0
Samples
val file = tempDir.newFile("target").toFile()
expect(file)
.asPath() // subject is now of type Path
.toBeARegularFile()
fails {
expect(file)
.asPath() // subject is now of type Path
.toBeADirectory() // fails
.notToStartWith(tempDir) // not evaluated/reported because `cause` already fails
// use `.asPath { ... }` if you want that all assertions are evaluated
}
Expects that the subject of this
expectation holds all assertions the given assertionCreator creates for the subject as Path.
The transformation as such is not reflected in reporting. Use feature(File::toPath, assertionCreator)
if you want to show the transformation in reporting.
Return
an Expect for the subject of this
expectation.
Since
0.9.0
Samples
val file = tempDir.newFile("target").toFile()
expect(file).asPath { // subject within this expectation-group is of type Path
toBeARegularFile()
toStartWith(tempDir)
} // subject here is back to type File
fails {
// all expectations inside an expectation-group are evaluated together; for more details see:
// https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group
expect(file).asPath {
toBeADirectory() // fails
notToStartWith(tempDir) // still evaluated even though `toBeADirectory` already fails
// use `.asPath().` if you want a fail fast behaviour
}
}