     }
 }
 
+/// Appends a subdirectory to the given string representing a folder filepath. If the provided
+/// subdirectory is an empty string, this simply returns the original path.
+/// - Parameter path: String representing target directory
+/// - Parameter subDirectory: String representing the subdirectory you wish to append to path
+/// - Returns: The new subdirectory path under the original path
+func appendSubdirectoryToPath(_ path: String, subDirectory: String) -> String {
+    if subDirectory.isEmpty {
+        return path
+    }
+
+    return path.last == "/" ? path + subDirectory : path + "/" + subDirectory
+}
+
 
 // ====== main ======
 

var excludeIdenticalScreenshots = excludeIdenticalScreenshotsOptionValue != nil

let logsTestPath = logsTestPathOptionValue!
let testSummariesPlistJson = getTestSummariesPlistJson(logsTestPath: logsTestPath)

// save the last screenshots if --screenshotsPath option is passed
if let screenshotsPathOptionValue = screenshotsPathOptionValue {

if let jUnitReportPathOptionValue = jUnitReportPathOptionValue {
    argumentOptionsParser.validateOptionIsNotEmpty(optionName: jUnitReportPathOption, optionValue: jUnitReportPathOptionValue)

    var fileCount = 1
    var subDirectory = testSummariesPlistJsons.count > 1 ? "\(fileCount)" : ""

    testSummariesPlistJsons.forEach { testSummariesPlistJson in
        generateJUnitReport(testSummariesPlistJson: testSummariesPlistJson, logsTestPath: logsTestPath, jUnitRepPath: appendSubdirectoryToPath(jUnitReportPathOption, subDirectory: subDirectory) , noCrashLogs: noCrashLogs, lastScreenshotsPath: screenshotsPathOptionValue, screenshotsCount: screenshotsCount, buildUrl: buildUrlOptionValue, workspacePath: workspacePathOptionValue ?? "")
        fileCount += 1
        subDirectory = "\(fileCount)"
    }

}
