Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve temporary file handling in test #180

Open
occupant23 opened this issue Apr 28, 2021 · 0 comments
Open

Improve temporary file handling in test #180

occupant23 opened this issue Apr 28, 2021 · 0 comments

Comments

@occupant23
Copy link
Contributor

Current solution:
Add a file to a List in NeodymiumTest and the inherited @AfterClass method will delete them after the test.

// create a file 
File file = new File(PATH);
// add it to the list
NeodymiumTest.tempFiles.add(file);

// this function will take care of the rest
@AfterClass
public static void cleanUp()
{
    for (File tempFile : tempFiles)
    {
        deleteTempFile(tempFile);
    }
}

An alternative solution could be to use the appropriate interface of File

File tempConfigFile = new File(PATH);
tempConfigFile.deleteOnExit();
// interact with the file
writeMapToPropertiesFile(properties, tempConfigFile);

Please validate this approach and remove the old approach and all unused functions if this works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant