How to Zip the Report Folder


How can we use the Command Line in Windows when running a script?

Saw this document but was not successful on my code.

Do I need to add something on my command below for it to work:

When I tried the command below in CMD I can zip the folder:
powershell Compress-Archive C:\Users.…\Reports\20210930_142534\Test\Login C:\Users.…\Reports\20210930_142534\Test\

Kindly advice on how I can get this working, thank you so much

you wrote you could zip it.
then what is your question?

if you still couldnt, show us error messages you got.

Sorry for the confusion.

Is when I manually enter the command in CMD.

Whoever if I use either Runtime.getRuntime().exec(strCommand) or Runtime.runtime.exec(strCommand) it does not zip the folder during runtime

@kazurayam there’s no any error in console when I use Runtime.getRuntime().exec(strCommand) or Runtime.runtime.exec(strCommand)

In Log viewer I can only see it did run that line of code:
09-30-2021 04:03:43 PM getRuntime().exec(strCommand)

Elapsed time: 0.021s

Please check Console tab, not only Log Viewer

@kazurayam I do always check both Console and Log Viewer. I added comments before and after for you to verify:



Log Viewer:

It does not show or log any error


Upon checking the exec needs an array hence updated the command. Code below is working:

String[] arrCommand = ["cmd", "/c", "powershell Compress-Archive " + 
	strParentFolderPath + " " + strParentFolderPath + ".zip"]

However these lines of code will not compress the folder during runtime. That’s just my observation since if I run the above code separately it can compress the folder.

Maybe someone can further explain why it behaves like that.

Also, my goal was to upload this zipped file somewhere if the Test Suite failed but I think its not feasible since the generation of report files will only happen at the end of the AfterTestSuite.

Can we call the generate reports in AfterTestSuite? Or someone has a better idea on this. Please advice

Regarding your Report capture:
The only way you can reasonably accomplish what you are trying to do is to create a second suite and run them both sequentially.

  1. Suite One is your current suite which builds the report you want to archive.

  2. Suite Two contains a single test case which performs the archive steps.

There are other ways to do this where you have only Test Suite One. But they involve you building your own reports and ignoring the Katalon reports. That would also mean pretty much everything in TestOps would be useless to you since I don’t think there is an API for you to commit your custom reports to TestOps.

Regarding your zip problem:
I don’t know what is wrong there. I issue commands and run batch files from my suites all the time and it works fine. My advice would be to have your .exec(...) do something very simple, prove it works, then introduce your Zip steps.

@Russ_Thomas the issue I encounter is, I cannot zip the report folder at AfterTestSuite during runtime. Although now that I saw the generation of reports is after my codes its pretty useless since its contains no report at that point. But if I zip other folders outside the report I’m currently running, compress command works.

Thanks for your inputs regarding the Report Capture. Will be assessing my options. Have a nice day

That’s why I proposed Suite Two which executes AFTER Suite One has finished. That will allow you to workaround your issue.

I don’t say this ideal – but it should work.

1 Like


"powershell Compress-Archive "


"powershell", "Compress-Archive"
1 Like

@kenneth.montevirgen just wrap your katalon execution into a script (powershell, batch, bash, whatever else, depending on your execution environment)
to do the zip and upload steps straight into the test project makes your test suite prone to errors.

the post-processing of the test results is to be independent of the test execution and should not fail the test if an error occur during the post-processing steps
this is the preferred way in any CI tool

Even i faced the same issue. We can zip the folder… but nothing inside the report folder since report generation is at last. I hope, if we can add report generation at after Test suite then it will be helpful.
The workaround of adding 2 test suite and then call the them as a test suite collection, that works for me. but still that is not a normal approach.

the normal approach is to post-process any report after the scope of the entire build ends.
this is valid also for maven and gradle builds or any other automated testing tool.
the reports are generated after the scope of the test suite ends, so you cannot process the reports until the scope of the build ends completely.

I have made another post

there I showed a demo how to zip a Report folder of a Test Suite. I applied what I call “Post TestSuite processing” approach: the output from a Test Suite is post-processed by a following Test Suite.

1 Like