File steps
This plugin provides steps to operate on local files and directories during test execution. It is useful in end-to-end scenarios where the system creates, modifies, copies, moves, or deletes files.
-
- Define timeout
- Move file or directory to a directory
- Move file or directory to a file
- Copy file or directory to a directory
- Copy file or directory to a file
- Delete file or directory
- Wait for deletion
- Wait for modification
- Wait for creation
- Check file exists
- Check file does not exist
- Check file text content
- Check file content by ranges
- Check file length
Install
Include the module in the corresponding section.
es.iti.wakamiti:io-wakamiti-plugin:2.7.0
es.iti.wakamiti:io-wakamiti-plugin:2.7.0
<dependency>
<groupId>es.iti.wakamiti</groupId>
<artifactId>io-wakamiti-plugin</artifactId>
<version>2.7.0</version>
</dependency>
<dependency> <groupId>es.iti.wakamiti</groupId> <artifactId>io-wakamiti-plugin</artifactId> <version>2.7.0</version> </dependency>
Options
files.timeout
- Type:
long - Default:
60
Maximum wait time in seconds for file wait steps.
Example:
files:
timeout: 120
files.enableCleanupUponCompletion
- Type:
boolean - Default:
false
If enabled, tracked file operations are automatically cleaned up at the end of execution.
Example:
files:
enableCleanupUponCompletion: true
files.links
- Type:
string
Defines symbolic links created during setup.
Format: source=target, separated by commas or semicolons.
Example:
files:
links: "./tmp/incoming=./runtime/incoming; ./tmp/out=./runtime/out"
Steps
Define timeout
a file timeout of {value} seconds
a file timeout of {value} secondsDeclarative way to set the configuration property files.timeout.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
value | long required | Timeout in seconds |
Examples:
Given a file timeout of 120 seconds
Move file or directory to a directory
the (file|directory) {src} is moved to directory {dest}
the (file|directory) {src} is moved to directory {dest}Moves a file or directory to a target directory.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
src | file required | Source file or directory |
dest | file required | Destination directory |
Examples:
When the file 'tmp/report.txt' is moved to directory 'archive'
Move file or directory to a file
the (file|directory) {src} is moved to file {dest}
the (file|directory) {src} is moved to file {dest}Moves a file or directory to a specific destination path.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
src | file required | Source file or directory |
dest | file required | Destination file path |
Examples:
When the file 'tmp/report.txt' is moved to file 'archive/report-old.txt'
Copy file or directory to a directory
the (file|directory) {src} is copied to directory {dest}
the (file|directory) {src} is copied to directory {dest}Copies a file or directory to a target directory.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
src | file required | Source file or directory |
dest | file required | Destination directory |
Examples:
When the file 'template.txt' is copied to directory 'out'
Copy file or directory to a file
the (file|directory) {src} is copied to file {dest}
the (file|directory) {src} is copied to file {dest}Copies a file or directory to a specific destination path.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
src | file required | Source file or directory |
dest | file required | Destination file path |
Examples:
When the file 'template.txt' is copied to file 'out/generated.txt'
Delete file or directory
the (file|directory) {file} is deleted
the (file|directory) {file} is deletedDeletes a file or directory.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File or directory to delete |
Examples:
When the directory 'tmp/data' is deleted
Wait for deletion
the (file|directory) {file} deletion is awaited
the (file|directory) {file} deletion is awaitedWaits until a file or directory is deleted, up to the configured timeout.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File or directory to watch |
Examples:
When the file 'out/processing.lock' deletion is awaited
Wait for modification
the (file|directory) {file} modification is awaited
the (file|directory) {file} modification is awaitedWaits until a file or directory is modified, up to the configured timeout.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File or directory to watch |
Examples:
When the file 'out/report.txt' modification is awaited
Wait for creation
the (file|directory) {file} creation is awaited
the (file|directory) {file} creation is awaitedWaits until a file or directory is created, up to the configured timeout.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File or directory to watch |
Examples:
When the file 'out/report.txt' creation is awaited
Check file exists
the file {file} exists
the file {file} existsVerifies that the file exists.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File path to check |
Examples:
Then the file 'out/report.txt' exists
Check file does not exist
the file {file} not exists
the file {file} not existsVerifies that the file does not exist.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File path to check |
Examples:
Then the file 'tmp/old-report.txt' not exists
Check file text content
the file {file} contains the following text:
{data}
the file {file} contains the following text:
{data}Verifies that the full file text matches the given in-document content.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File path to check |
data | document required | Expected full text |
Examples:
Then the file 'out/report.txt' contains the following text:
"""
Status: OK
"""
Check file content by ranges
the file {file} contains the following data:
{table}
the file {file} contains the following data:
{table}Verifies fragments of the file content by character ranges.
The data table must include columns: from, to, value.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File path to check |
table | table required | Ranges and expected values (from,to,value) |
Examples:
Then the file 'out/report.txt' contains the following data:
| from | to | value |
| 0 | 6 | Status |
| 8 | 10 | OK |
Check file length
the file {file} has length of {chars}
the file {file} has length of {chars}Verifies that the file length in bytes is equal to the provided number.
Parameters:
| Name | Wakamiti type | Description |
|---|---|---|
file | file required | File path to check |
chars | integer required | Expected file length in bytes |
Examples:
Then the file 'out/report.txt' has length of 128