Skip to content

Commit

Permalink
feat: added logging of variables of test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattebit committed Dec 14, 2023
1 parent f3fa7c9 commit e358c03
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tool/src/main/java/migt/Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ public void logTest(String log_folder) {
String test_log_folder = log_folder + "/" + timestamp + "/" + this.name + "/";
String matched_folder = test_log_folder + "matched/";
String all_path = test_log_folder + "all/";
String test_log_path = test_log_folder + "test.log";
File directory = new File(test_log_folder);
if (!directory.exists()) {
if (!directory.mkdirs()) {
Expand All @@ -271,6 +272,24 @@ public void logTest(String log_folder) {
}
}

String test_log_content = "Name: " + this.name + "\n";

test_log_content += "Variables: \n";

for (Var v : vars) {
test_log_content += v.name=v.value+"\n";
}

File test_log = new File(test_log_path);
try {
FileWriter fw = new FileWriter(test_log.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(test_log_content);
bw.close();
} catch (IOException e) {
e.printStackTrace();
}

for (Session s : this.sessions) {
if (s.name.equals("")) {
continue;
Expand All @@ -288,7 +307,8 @@ public void logTest(String log_folder) {
Integer op_count = 0;
for (Operation o : this.operations) {
Integer message_count = 0;
String header = "========================= Info ===========================\n";
String header = "===================== Session Info =========================\n";
header += "===================== Message info =========================\n";
header += "=\t" + "Intercepted from session: " + o.from_session + "\n";
header += "=\t" + "Message name: " + o.getMessageType() + "\n";
header += "==========================================================\n";
Expand Down

0 comments on commit e358c03

Please sign in to comment.