Add a file to report folder

Hi,

I’m currently working on test integration.

I’m using Jenkins and TestOps. I found out that we can access files after a test suite run.

I want to create custom report because the plugins open source are not what we want.

I tried this code

File directoryPath = new File("Reports/");
String[] contents = directoryPath.list();
String last_folder_created = contents[contents.length-2]
File file = new File("Reports/" + last_folder_created + "/<Test Suite Name>/" + last_folder_created + "/customReportFile.txt")

The path i mentioned here is the path that is visible when you want to access reports in the testOps app.

image
But since this path is generated at the end of the test suite, is it possible to add a file that can be accessible in the testOps file review ?

FAO @devalex88 @duyluong @ThanhTo @Jass

Hi @cmta.support,

Sorry for my late response,

The current mechanism of KS is to upload files in supported formats (like .txt, .csv,…) so the answer is it’s possible.

I’ve tried to create a file with below snippet, and it works:

File directoryPath = new File('Reports/')
File[] files = directoryPath.listFiles();
if (files == null || files.length == 0) {
	return null;
}

File lastModifiedFile = files[0];
for (int i = 1; i < files.length; i++) {
   if (lastModifiedFile.lastModified() < files[i].lastModified()) {
	   lastModifiedFile = files[i];
   }
}

String last_folder_created = lastModifiedFile.getName()

File file = new File(((('Reports/' + last_folder_created) + '/Simple TS/') + last_folder_created) + '/customReportFile.csv')

boolean successful = file.createNewFile()

Below is the result:

Regards,
Nam Nguyen.