From 2acdc0c7a53593a141e7e9ff6997e166b5a06e18 Mon Sep 17 00:00:00 2001 From: Matteo Bitussi Date: Wed, 21 Feb 2024 13:36:37 +0100 Subject: [PATCH] feat: added logging of suite result in csv --- tool/src/main/java/migt/TestSuite.java | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tool/src/main/java/migt/TestSuite.java b/tool/src/main/java/migt/TestSuite.java index 65e5d2d..17a4196 100644 --- a/tool/src/main/java/migt/TestSuite.java +++ b/tool/src/main/java/migt/TestSuite.java @@ -1,5 +1,7 @@ package migt; +import org.apache.commons.text.StringEscapeUtils; + import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; @@ -55,7 +57,7 @@ public void log_test_suite(String log_folder_path) { } String log_content = ""; - log_content += "| test name | description | type | result | applicable |\n"; + log_content += "| name | description | type | result | applicable |\n"; log_content += "|-----------|-------------|------|--------|------------|\n"; for (Test t : tests) { @@ -77,6 +79,27 @@ public void log_test_suite(String log_folder_path) { } catch (IOException e) { e.printStackTrace(); } + + String log_content_csv =""; + log_content_csv += "name,description,type,result,applicable\n"; + for (Test t : tests) { + log_content_csv += + StringEscapeUtils.escapeJava(t.name.replaceAll(",","")) + "," + + StringEscapeUtils.escapeJava(t.description.replaceAll(",","")) + "," + + (t.isActive ? "active" : "passive") + "," + + t.success + "," + + t.applicable + "\n"; + } + + File log_suite_csv = new File(test_log_folder + "results.csv"); + try { + FileWriter fw = new FileWriter(log_suite_csv.getAbsoluteFile()); + BufferedWriter bw = new BufferedWriter(fw); + bw.write(log_content_csv); + bw.close(); + } catch (IOException e) { + e.printStackTrace(); + } }