3

In a Cargo project, where would you put files that exist solely to support testing?

For example, if you were writing a CSV parsing library, you might want example CSV files to parse in tests. Or if you were writing an image processor, you might want example images.

Ideally, users of the library would not be bothered with these, especially if they are large.

Nathan Long
  • 122,748
  • 97
  • 336
  • 451

1 Answers1

2

Wherever you want, there's no officially suggested place.

See also:

users of the library would not be bothered with these

That's what the package.exclude configuration is for.

As Sven Marnach points out

If you choose to ignore some test assets, consider writing the tests in a way that they also pass when the assets are missing. This allows Crater to test your crate successfully.

One way to accomplish this is to put additional tests behind a feature flag. Only enable that flag in your own CI.

See also:

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
  • 1
    If you choose to ignore some test assets, consider writing the tests in a way that they also pass when the assets are missing. This allows Crater to test your crate successfully. – Sven Marnach Apr 08 '20 at 19:03