How to Modify ATEasy HTML Test Log Tests Table

Knowledge Base Article # Q200305

Read Prior Article Read Next Article
Summary Example of modifying HTML Test Log in order to add a new column for a time stamp to the tests tables for MinMax and Other test types.
  
Login to rate article


This article is a step by step walk-through on how to change TestExec's HTML output log using FormatLogString() and GetLogString().

In this example, a new column for a time stamp will be added for the MinMax and Other test types.

It is recommended to only make modifications to the System Module (as shown in this example) or to create another driver.

It is not recommended to modify the TestExec driver, that way you can update ATEasy to new versions without worrying about losing your changes or re-merging your work.




Using FormatLogString to Change the Format of a Test Type

1. Insert the TestExec driver to your project.

Insert TestExec to your project.
Figure 1: Insert TestExec to your project.


2. In the System.OnEndTest() event use the GetLongString() procedure to find the original header and test strings.

GetLogString() in System.OnEndTest.
Figure 2: GetLogString() in System.OnEndTest.


The HTML strings for the header and tests are traced to the Debug Log:

The header string.
Figure 3: The header string for Min/Max tests.


The test string.
Figure 4: A test string for a Min/Max test.


3. Both strings need to be modified to add a new column for the time stamp. In this example the new column was added to the front and named "Time". After the time-stamp column was added, the strings were assigned to variables sHeader and sTest in the System.OnInitTest() event.

The modified strings assigned to sHeader and sTest.
Figure 5: The modified strings assigned to sHeader and sTest.


Note:
  • In this example the strings were separated into different lines for readability. Leaving the string as one line is also valid.
  • Put a backslash before each of the inner quotations to use quotation marks inside of a string declaration. Ie: sString="Bob said "hello" to Joe." becomes sString="Bob said \"hello\" to Joe."
  • In sTest, the procedure STime() is used to get the current time.
  • In sTest, FONT COLOR was removed from the Status field because ATEasy will add the color automatically when the test status is evaluated.
  • The data in the sTest string need to be replaced by the appropriate field parameters. For more information on the field parameters, use the ATEasy Help (F1) and search for "FormatLogString" in the Index tab.

4. In the System.OnInitTest() event use the FormatLogString() procedure to change the format of Min/Max tests. Be sure to use "atestTypeMinMax" as the input for the enTestType parameter to specify the Min/Max test.

The System.OnInitTest() event should look like Figure 6:

FormatLogString in System.OnInitTest().
Figure 6: FormatLogString in System.OnInitTest().


5. Run the project in TestExec to see the new format for Min/Max tests.

TestExec with time stamps added to Min/Max tests.
Figure 8: TestExec with time stamps added to Min/Max tests.


Polish Before Moving On

6. Notice an issue with the test log; the Min/Max tests are repeating the header for every consecutive Min/Max test. This occurs because TestExec prints the header if a new header format is applied. We can accommodate this behavior by only applying the modified test header once per task.

To start we need to add a couple of variables. Since we have been making our time-stamp changes to the System Module, we will place these new variables into the System Module's Variables.

Variables
================================================================================
lPreviousTaskNumber: Long       ! Keeps track of the most recent task number that was ran.
ucTestedTypesFlags: Byte ! Each bit keeps track on whether a test type's header had been applied.
! Bit / Test Type
! 0 / MinMax
! 1 / Other
! 2 / Ref2
! 3 / RefX
! 4 / Tolerance
! 5 / Precise
! 6 / String


Now we add some code to only apply the header once per task. To do this, our application first needs to check if the current test's task number is different than the previous. If it is different, reset our ucTestedTypesFlags variable.

For each test type, we check the bit in the ucTestedTypesFlags variable for each respective test type. If the new format had not been applied for this task yet, it will apply the new header and test log format at the same time (using aFormatLogDefault). Then set the test type's bit in the ucTestedTypesFlags variable to 1, signifying that we have applied the header for this test. Since we are currently working on the Min/Max test, the bit we want to check/raise will be bit 0 (we have decided this in the comments of the ucTestedTypesFlags variable). If the test header was already applied in the current task (respective test type bit in ucTestedTypesFlags is 1), then we can exclude the header and only apply the new test string format (using aFormatLogIgnoresHeaderParameter).

Finally, we want to record the current task number to the variable lPreviousTaskNumber. It will be used to compare with the next test's task number to determine if the flags variable ucTestedTypesFlags needs to be reset. Figure 7 shows the final result of the System.OnInitTest() event.

Only apply header once per task.
Figure 7: Only apply header once per task.


Now when we run the program we see that the header is correctly shown once for consecutive Min/Max tests. Figure 8 shows the test log after adding a time-stamp to Min/Max tests.  

TestExec log with time-stamps for MinMax tests.
Figure 8: TestExec log with time-stamps for MinMax tests.


Repeat to Modify the Format of Another Test Type

7. Steps 2 through 6 can be repeated for another test type. Figure 9 below shows what the System.OnInitTest() event looks like after repeating steps 2 through 6 for the "Other" test type. Use "atestTypeOther" for the enTestType parameter in FormatLogString to specify the changes are for the test type "Other".

System.OnInitTest() event with Other test type modified.
Figure 9: System.OnInitTest() event with Other test type modified.


Tests of type Min/Max and Other now have a time stamp column.

Tests of type Min/Max and Other have a time stamp column added.
Figure 10: Tests of type Min/Max and Other have a time stamp column added.


Download

The project included below was completed to add the time-stamp column for all test types (MinMax, Other, Precise, Ref2, RefX, String, and Tolerance).
DownloadClick here to download the example project used in this article as a .ZIP.
Article Date 2/24/2017 , 9/8/2021
Keywords TestExec Test Executive Exec HTML Log FormatLogString GetLogString


Login to rate article

1 ratings | 5 out of 5
Read Prior Article Read Next Article