magISCO
magISCO

Reputation: 1

Files to test in JUnit

I'm currently writing tests to a class. And this class takes in two files in its constructor. So I need to create two files to initialize an object of that class. So what's the best way to do that? Simply create a .txt in the project directory or what? Thanks in advance

Upvotes: 0

Views: 58

Answers (2)

en1010
en1010

Reputation: 1300

I advise to use Maven Project. There would be a good point to do that - src/test/resources

UPD: gradle has similar directory structure:

https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_project_layout

Upvotes: 1

Andy Turner
Andy Turner

Reputation: 140328

Create a TemporaryFolderrule, and create files in there.

This will ensure that they are cleaned up after the test has been run, you don't get interference between tests etc.

Upvotes: 1

Related Questions