Construct unique safe filenames in TestNG
In order to save files for investigating failures from within TestNG it’s important to have a safe filename that is unique to the test – otherwise you may overwrite important files. I have written the following simple method in Java that is called from a listener with an ITestResult
parameter to construct a unique file name that should be safe on most file systems.