Skip to content

Documentation error and issue with cleaning up files after testing #2045

@mattwarkentin

Description

@mattwarkentin

Hi,

I think there is an issue with the documentation shown here: https://testthat.r-lib.org/articles/test-fixtures.html#package

Source code here:

```{r, eval = FALSE}
# Run before any test
write.csv("mtcars.csv", mtcars)
# Run after all tests
withr::defer(unlink("mtcars.csv"), teardown_env())
```

The arguments are backwards for write.csv(). Moreover, I don't know that the suggested pattern works anyway for cleaning up files. At least I am unable to reproduce the desired behaviour. See the post here for a more complete real-world example: https://forum.posit.co/t/cleaning-up-temporary-files-after-testing-not-working-as-expected/196516

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions