I would introduce Materials, a java/groovy library that resolves output file paths in a well-structured format. The
com.kazurayam.materials.MaterialRepository class provides convenient methods with which I can solve the above-mensioned problems easily.
resolveMaterialPath(String testCaseId, String fileName)method returns
java.nio.file.Pathobject for a File to be created. The path would be in the format of
makeIndex()method generates the
./Materials/index.htmlfile. This is a simple viewer for the
Test Suites/TS_Materials_appliedand run it.
This project is based on the katalon-studio-samples/jira-api-tests project. I added a few codes on it without changing files of the original project.
Test Suites/TS_Materials_applied executes
Test Cases/Simple examples/api-2-issue/Get issue/Get an issue by Key - 1 - Materialized. The test case code looks like this:
// Send the request and get the response response = WS.sendRequest(findTestObject('Simple examples/api-2-issue/Get issue/Get an issue by Key')) // Verify the response WS.verifyResponseStatusCode(response, 200) // make MaterialRepository accessible MaterialRepository mr = (MaterialRepository)GlobalVariable.MATERIAL_REPOSITORY // store the HTTP Response Headers into file Path path2 = mr.resolveMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, "headers.json") Map<String, List<String>> headerFields = response.getHeaderFields() String headersJson = CustomKeywords.'com.kazurayam.ksbackyard.WebServiceTestSupport.convertHeaderFieldsToJsonString'(headerFields) path2.toFile().append(headersJson, 'utf-8') // store the HTTP Response Body into file Path path3 = mr.resolveMaterialPath(GlobalVariable.CURRENT_TESTCASE_ID, "body.json") String body = response.getResponseBodyContent() path3.toFile().append(body, 'utf-8')
This test case send a HTTP GET request to a RESTFul URL https://katalon.atlassian.net/rest/api/2/issue/KD-1000?expand=names&fields=summary,status,issuetype,assignee,project,priority,description&= . The test case makes a bit of assertions over the response. And it writes the HTTP Response Headers and Body into files on local disk in JSON format.
Test Suites/TS_Materials_applied, a new folder
<projectDir>/Materials will be created. In there you can find a folder tree and a HTML file named
You can browse the index.html. It will look like this:
In the index you will find as many records of test suite runs as you executed. In the above screenshot, you can find 3 times of test suite run recorded.
Each test suite run contains a record of test case run, which contains links to the files created.
By clicking the links, you can view the files in modal widdow. Here is
The created files has a path like this:
A concrete path example:
./Materials/TS_Materials_applied/20181018_140249/Simple examples.api-2-issue.Get issue.Get an issue by Key - 1 - Materialized/header.json
Please note that this folder tree contains a timestamp layer
yyyyMMdd_hhmmss. Having a timestamp layer enables you to retain outputs as long as you like until you intensionally delete them. This chronological folder structure is best fit for logging purpose.
Here I would describe, step by step, for you how to recreate a Katalon Studio project which has the Materials library builting and enabled.
MATERIALS_REPOSITORYwith type Null. Add
CURRENT_TESTCASE_IDwith type String.
Test Cases/cleanMaterialsin your project. Copy and paste the source of
Test Cases/clearMaterials. You need not to change the code at all.
Test Cases/makeIndexin your project. Copy and paste the source of
Test Cases/makeIndex. You need not to change the code at all.
cleanMaterials, your own test case and
makeIndex. . The test suite can have any name you like.
Run. In the Run row, there are toggle controls. You can choose each test cases to run or not. If you toggle on the
cleanMaterialstest case, then the
./Materialsdirectory will be cleaned every time when the test suite runs. If you toggle off, then you can see multiple records of test sute runs accumulated in the index.html viewer.
It looks like you're new here. If you want to get involved, click one of these buttons!