Skip to main content
Posted On 27 Mar 2023

I agree to Privacy Policy

This article explains the steps how to generate reports using TC Shell, by parametrizing the property and input details rather than hardcoding the same.

Situation:

We have a common use case where we have to run the test executions at scheduled times and unattended via TC Shell. In such cases it is desirable to create a .tcs file and .bat file with commands, instructions and input in the files which are hard coded and can be used only for one execution list. If we have to use it for more than one execution list then either we need to edit the same files or create new one.

Solution:

We can solve the above situation by following below steps and creating .tcs file and .bat file at the time of execution and then generate a report.

  1. We would start by checking the value of the property “PrintOutputFormat” is set to “NONE” or not, for Report Definition. To do so, navigate to the reporting section in Tosca Commander and click on Report Definition (Commonly known as report which needs to be printed), example – “ExecutionEntries with detailed Logs”.

  2. Now, open Properties pane at the extreme right of Tosca Commander and check for property “PrintOutputFormat” as in Fig. 01 and set it to “NONE” as in Fig. 02

    Fig. 01

    Fig. 02

  3. Once we set the “PrintOutputFormat” property we must define a value of the setting “DefaultPrintOutputFormat” as “ASKUSER” which will enable TC Shell to take input from the user when we provide format in the .tcs file.

  4. To set the value of setting “DefaultPrintOutputFormat” please navigate to the path - “C:\Program Files (x86)\TRICENTIS\Tosca Testsuite\ToscaCommander” (Fig. 03) and copy “TC Shell.exe.config” (Fig. 03) file from the path and paste at the path – “C:\ProgramData\TRICENTIS\Tosca Testsuite\7.0.0\Settings” (Fig. 04)

    Fig. 03

    Fig. 04

  5. Now, Open the TC Shell.exe.config file in Admin mode in Notepad or Notepad++ from path – “C:\ProgramData\TRICENTIS\Tosca Testsuite\7.0.0\Settings” (Fig. 04) and look for section group name = “user settings” tag (Fig. 05) highlighted in the figure. Under section group tag at the end add section name for Reporting AddIn which was not a part of Original file (Fig. 06)

    Reporting AddIn:

    Fig. 05

    Fig. 06

  6. Once you have added the section name for Reporting AddIn successfully, we must now add user setting for Reporting AddIn. Look for user settings tag as in Fig. 07 and then add user setting for Reporting AddIn as in Fig. 08

    User Setting for Reporting AddIn:

    Fig. 07

    Fig. 08

  7. Now, save the TC Shell.exe.config file. This would allow TC Shell to create reports without any user interaction

  8. Now we will create a test case/RTB to create .tcs file (to interact and perform activities in Tosca workspace) first and then .bat file (to open TC Shell and login to the workspace) at runtime

  9. Open Tosca Commander and navigate to Test Case section and create a test case. Now, drag “TBox Read/Create File” standard module and drop in a test case to create a test step.

    • Directory attribute: Provide value of Directory where you would like to save .tcs file created at runtime
    • File attribute: Give .tcs Filename in the value field.
    • Text attribute: Enter the text which we need to be the part of .tcs file. Refer Fig. 09 for clarity. Overwrite attribute should be Yes as in Fig. 09

    .tcs file content:
    UpdateAll
    JumpToNode """"{B[ExecutionListNodePath]}""""
    task """Print Report ... "{B[ReportDefinition]}""""
    """"{B[ReportPath]}"\\"{B[ReportFilename]}""""

    Fig. 9

  10. Now, we will create a test step for .bat file creation. To do so we will use “TBox Read/Create File” standard module as we did for .tcs file

    • Directory attribute: Provide value of Directory where you would like to save .bat file created at runtime
    • File attribute: Give .bat Filename in the value field.
    • Text attribute: Enter the text which we need to be the part of .bat file. Refer Fig. 10 for clarity. Overwrite attribute should be Yes as in Fig. 10

    .bat file content – when workspace is created using Tricentis Server Repository:

    TC Shell.exe -workspace “””C:\Tosca_Projects\Tosca_Workspaces\”{B[WorkspaceName]}”\”{B[WorkspaceName]}”.tws””” -auth “”””{B[Auth]}”””” -login “”””{B[AOS_User]}”””” “”””{B[Password]}”””” -executionMode “”””{B[tcsBatFolderPath]}”\”{B[tcs_FileName]}””””

    Note: Command “-auth” is used here as we have created our workspace using “Tricentis Server Repository” which needs to Authenticate user when it logs in to the workspace. Variable “Auth” has a value of Authentication token which is generated for the user from “User Administration” of “Tosca Server”. 

    If you have created workspace normally using connection string then use below .bat file content.

    .bat file content – When Workspace is created using connection strings and not from Tricentis Server Repository:

    TC Shell.exe -workspace
    “””C:\Tosca_Projects\Tosca_Workspaces\”{B[WorkspaceName]}”\”{B[WorkspaceName]}”.tws””” -login “”””{B[AOS_User]}”””” “”””{B[Password]}”””” -executionMode “”””{B[tcsBatFolderPath]}”\”{B[tcs_FileName]}””””

    Fig. 10

  11. Now add a test step using “TBox Start Program” standard module to execute the created .bat file and provide path along with file name as in Fig. 11. You can create an RTB as well for the execute step (optional)

    Fig. 11

    Here, we are fetching details from a buffer variable as seen in the content and Figs. 09, 10 & 11 which we need as Dynamic. Escape characters have been used to get the buffer values translated which will be added as a .tcs and .bat file content.

    These buffer values can be set from the configuration parameters or TDS repository and called in an RTB to be used, which will make the reporting parametrized and dynamic Values of the buffer variables used in the blog. Refer Fig. 12

    Fig. 12

  12. Below are the contents of the created .tcs & .bat file

    Created .tcs file content:

    UpdateAll JumpToNode "/Execution/ExecutionLists/DB | Demo Scripts" task "Print Report ... ExecutionEntries with ActualLog and Issues" "C:\\Tosca_Projects\\ExecutionReports\\ERTest\\07.03.2023\\ERTest_07032023-180728.pdf"

    Created .bat file content:

    TC Shell.exe -workspace "C:\Tosca_Projects\Tosca_Workspaces\TOSCACOE\TOSCACOE.tws" -auth "******" -login "****" "****" -executionMode "C:\Tosca_Projects\ExecutionReports\tcsBatFiles\ExecutionFile.tcs"

  13. We may need to send the generated report to Stake holders. In order to do so please keep the test case which will create these .tcs and .bat files at the end of the test case and Modify the .tcs content in Text attribute of Step 09c with below content.

    .tcs file content to send email:

    UpdateAll JumpToNode """"{B[ExecutionListNodePath]}"""" task """Print Report ... "{B[ReportDefinition]}"""" """"{B[ReportPath]}"\\"{B[ReportFilename]}"""" JumpToNode """"{B[ExecutionListNodePathSendMail]}"""" task """Checkout Tree""" task """Run""" save CheckinAll

  14. In this content it can be seen that we are first generating report and then we jump to the Node of the execution list which has Send Mail test case. Steps after that will perform Checkout tree, execute the execution list with Send Mail test case, save the result and then perform CheckinAll.

  15. Refer Blog - Automate Send Mail Process after Report generation in Tosca using TC Shell for detailed steps of Automating the send mail process

Category