> For the complete documentation index, see [llms.txt](https://bernardo.gitbook.io/development-docs-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bernardo.gitbook.io/development-docs-java/testing/junit/test-files.md).

# Test Files

## JUnit 4

The TemporaryFolder rule allows creating testing folders.

```java
@Rule
public TemporaryFolder folder = new TemporaryFolder();
```

```java
file = folder.newFile("/file.txt");
```

## JUnit 5

The TempDir annotation initializes a testing folder.

```java
@TempDir
public static File folder;
```

Which can be used for creating test files:

```java
file = new File(folder, "/file.txt");
```
