Runtime Test Services: Difference between revisions

From STRIDE Wiki
Jump to navigation Jump to search
Line 11: Line 11:
The following C APIs are provided:  
The following C APIs are provided:  


*'''[[#srTestSuiteSetName|srTestSuiteSetName]]''': sets the name of the specified suite.
*'''[[#srTestGetParam|srTestGetParam]]''': returns an input parameters value.
*'''[[#srTestSuiteSetDescription|srTestSuiteSetDescription]]''': sets the description of the specified suite.
 
*'''[[#srTestSuiteAddSuite|srTestSuiteAddSuite]]''': creates an additional sub-suite at runtime<ref name=dynamic>
*'''[[#srTestSuiteAddCase|srTestSuiteAddCase]]''': creates an additional test case at runtime.
The use of these functions in the context of any test method will cause the STRIDE Test Unit framework to
'''delete''' the default test case that was created for the current test method since their use implies that dynamic test cases will be created. In addition, the use of the dynamic test case creation methods will cause the framework to interpret the '''srTEST_CASE_DEFAULT''' value as the most recently created test case.</ref>.  
*'''[[#srTestSuiteAddCase|srTestSuiteAddCase]]''': creates an additional test case at runtime<ref name=dynamic/>.  
*'''[[#srTestSuiteAddAnnotation|srTestSuiteAddAnnotation]]''': creates a suite annotation at runtime.  
*'''[[#srTestSuiteAddAnnotation|srTestSuiteAddAnnotation]]''': creates a suite annotation at runtime.  
*'''[[#srTestSuiteSetData|srTestSuiteSetData]]''': associates a custom name|value.


*'''[[#srTestCaseSetName|srTestCaseSetName]]''': sets the name of the specified test case.
*'''[[#srTestCaseSetDescription|srTestCaseSetDescription]]''': sets the description of the specified test case.
*'''[[#srTestCaseSetStatus|srTestCaseSetStatus]]''': explicitly sets the status for the specified test case.
*'''[[#srTestCaseSetStatus|srTestCaseSetStatus]]''': explicitly sets the status for the specified test case.
*'''[[#srTestCaseAddComment|srTestCaseAddComment]]''': adds a comment to the specified test case.
*'''[[#srTestCaseAddAnnotation|srTestCaseAddAnnotation]]''': creates a test case annotation at runtime.  
*'''[[#srTestCaseAddAnnotation|srTestCaseAddAnnotation]]''': creates a test case annotation at runtime.  
*'''[[#srTestSuiteSetData|srTestSuiteSetData]]''': associates a custom name|value pair with the specified test case.


*'''[[#srTestAnnotationAddComment|srTestAnnotationAddComment]]''': adds a comment to the specified annotation.
*'''[[#srTestAnnotationAddComment|srTestAnnotationAddComment]]''': adds a comment to the specified annotation.




==== srTestSuiteSetName ====
==C==
The srTestSuiteSetName() routine is used to set the name of the specified test suite.
 
==== srTestGetParam ====
The srTestGetParam() function is used to get the value of a named parameter as a string.
<source lang=c>
<source lang=c>
srWORD srTestSuiteSetName(srTestSuiteHandle_t tTestSuite, const srCHAR * szName)
srWORD srTestGetParam(const srCHAR * szName, srCHAR * szValue, srDWORD dwSize, const srCHAR * szDefValue);
</source>
</source>


Line 39: Line 37:
| '''Description'''
| '''Description'''
|-
|-
| tTestSuite
| szName
| Input
| Input
| Handle to a test suite. srTEST_SUITE_DEFAULT can be used for the default test suite.
| Pointer to a null-terminated string that represents the name of the parameter. Cannot be null.
|-
| szValue
| Output
| Pointer to a block of memory to store the value of the parameter with a maximum size of <i>dwSize</i> chars
|-
|-
| szName
| dwSize
| Input  
| Input  
| Pointer to a null-terminated string representing the name of test suite. Cannot be null.
| Size in chars of the buffer pointed to by <i>szValue</i>
|-
| szDefValue
| Input (optional)
| Pointer to a null-terminated string that represents a default value in case the parameter is not specified. By setting this value to srNULL (or omitting it), you can use <i>srTestGetParam()</i> to test for the existence of a named parameter. If the named parameter doesn't exist, the function will return <i>srERR_HANDLE_INVALID</i>.
|}
|}
<br>
<br>
Line 56: Line 62:
|-
|-
| srERR  
| srERR  
| Null string passed in.
| Null or empty szName string passed in.
|-
|-
| srTEST_ERR_HANDLE_INVALID
| srERR_HANDLE_INVALID
| Invalid handle passed in.
| The named parameter is not found and <i>szDefValue</i> is set to srNULL.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
|}


Line 68: Line 71:
#include <srtest.h>
#include <srtest.h>


void tfsuite_setName(void)
#define MAX_VALUE_LEN 128
void tfsuite_getParam(void)
{
{
   srTestSuiteSetName(srTEST_SUITE_DEFAULT, "Setting name for default suite");
   srCHAR szValue[MAX_VALUE_LEN] = {0};
 
  srWORD wRet = srTestGetParam("ParamName", szValue, MAX_VALUE_LEN, "default value");
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_setName)
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif
#endif
</source>
</source>


==== srTestSuiteSetDescription ====
 
The srTestSuiteSetDescription() routine is used to set the description of the specified test suite.
==== srTestGetParamLong ====
The srTestGetParamLong() function is used to get the value of a named parameter as a long.
<source lang=c>
<source lang=c>
srWORD srTestSuiteSetDescription(srTestSuiteHandle_t tTestSuite, const srCHAR * szDescr)
srLONG srTestGetParamLong(const srCHAR * szName, srLONG lDefValue);
</source>
</source>


Line 89: Line 96:
| '''Description'''
| '''Description'''
|-
|-
| tTestSuite
| szName
| Input
| Input
| Handle to a test suite. srTEST_SUITE_DEFAULT can be used for the default test suite.
| Pointer to a null-terminated string that represents the name of the parameter.
|-
|-
| szDescr
| lDefValue
| Input  
| Input  
| Pointer to a null-terminated string representing the description of test suite. Cannot be null.
| Default value that is returned if the parameter is not found.
|}
|}
<br>
<br>
Line 102: Line 109:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srLONG
| Success
| Parameter value, or value specified by <i>lDefValue</i> if parameter isn't found.
|-
| srERR
| Null string passed in.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
|}


<source lang=c>
<source lang=c>
#include <srtest.h>
#include <srtest.h>
void tfsuite_setDescription(void)
 
void tfsuite_getParam(void)
{
{
   srTestSuiteSetDescription(srTEST_SUITE_DEFAULT,
   srLONG lVal = srTestGetParamLong("ParamName", -1);
                            "Setting description for default suite");
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_setDescription)
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif
#endif
</source>
</source>


==== srTestSuiteAddSuite ====
==== srTestGetParamDouble ====
The srTestSuiteAddSuite()<ref name=dynamic/> routine is used to add a new test suite to the specified test suite.
The srTestGetParamDouble() function is used to get the value of a named parameter as a double.
<source lang=c>
<source lang=c>
srTestSuiteHandle_t srTestSuiteAddSuite(srTestSuiteHandle_t tParent, const srCHAR * szName)
double srTestGetParamDouble(const srCHAR * szName, double dbDefValue);
</source>
</source>


Line 138: Line 136:
| '''Type'''
| '''Type'''
| '''Description'''
| '''Description'''
|-  
|-
| tParent
| szName
| Input
| Input
| Handle to the parent test suite to which new test suite is to be added. srTEST_SUITE_DEFAULT can be used for the default test suite.
| Pointer to a null-terminated string that represents the name of the parameter.
|-
|-
| szName
| dbDefValue
| Input  
| Input  
| Pointer to a null-terminated string that represents the name of test suite. If null, the default host naming scheme will be used.
| Default value that is returned if the parameter is not found.
|}
|}
<br>
<br>
Line 152: Line 150:
| ''' Description'''
| ''' Description'''
|-
|-
|srTestSuiteHandle_t
| double
| Handle of the newly created test suite. srTEST_SUITE_INVALID indicates failure to create test suite.
| Parameter value, or value specified by <i>dbDefValue</i> if parameter isn't found.
|}
|}


Line 159: Line 157:
#include <srtest.h>
#include <srtest.h>


void tfsuite_addSuite(void)
void tfsuite_getParam(void)
{
{
   srTestSuiteHandle_t subSuite =
   double dbVal = srTestGetParamDouble("ParamName", 0.5772156649);
  srTestSuiteAddSuite(srTEST_SUITE_DEFAULT, "tf Sub Suite");
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_addSuite)
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif
#endif
</source>
</source>


==== srTestSuiteAddCase ====
==== srTestSuiteAddCase ====
The srTestSuiteAddCase()<ref name=dynamic/> routine is used to add a new test case to the specified test suite.
The srTestSuiteAddCase() routine is used to add a new test case to the specified test suite.
<source lang=c>
<source lang=c>
srTestCaseHandle_t srTestSuiteAddCase(srTestSuiteHandle_t tParent, const srCHAR * szName)
srTestCaseHandle_t srTestSuiteAddCase(const srCHAR * szName, const srCHAR * szDescr)
</source>
</source>


Line 180: Line 177:
| '''Type'''
| '''Type'''
| '''Description'''
| '''Description'''
|-
| tParent
| Input
| Handle to the parent test suite to which new test case is to be added. srTEST_SUITE_DEFAULT can be used for the default test suite.
|-
|-
| szName  
| szName  
| Input  
| Input  
| Pointer to a null-terminated string that represents the name of test case. If null, the default host naming scheme will be used.
| Pointer to a null-terminated string that represents the name of the new test case. If null, the default host naming scheme will be used.
|-
| szDescr
| Input
| Pointer to a null-terminated string representing the description of the new test case. If null, description will be empty.
|}
|}
<br>
<br>
Line 195: Line 192:
|-
|-
| srTestCaseHandle_t  
| srTestCaseHandle_t  
| Handle of the newly created test case. srTEST_CASE_INVALID indicates failure to create test case.
| Handle of the newly created test case. srTEST_CASE_INVALID indicates failure to create a test case.
|}
|}


Line 208: Line 205:
     char szName[25];
     char szName[25];
     sprintf(szName, "dynamic test case %d", count);
     sprintf(szName, "dynamic test case %d", count);
     srTestCaseHandle_t test = srTestSuiteAddCase(srTEST_SUITE_DEFAULT, szName);
     srTestCaseHandle_t test = srTestSuiteAddCase(szName, "this is a dynamic test case");
    srTestCaseAddComment(test, NULL, "this is a dynamic test case");
     srTestCaseSetStatus(test, srTEST_PASS, 0);  
     srTestCaseSetStatus(test, srTEST_PASS, 0);  
   }
   }
Line 222: Line 218:
The srTestSuiteAddAnnotation() routine is used to add a new annotation to the specified test suite.
The srTestSuiteAddAnnotation() routine is used to add a new annotation to the specified test suite.
<source lang=c>
<source lang=c>
srTestAnnotationHandle_t srTestSuiteAddAnnotation(rTestSuiteHandle_t tParent,
srTestAnnotationHandle_t srTestSuiteAddAnnotation(srTestAnnotationLevel_e eLevel,
                                                  srTestAnnotationLevel_e eLevel,
                                                   const srCHAR * szName,  
                                                   const srCHAR * szName,  
                                                   const srCHAR * szDescr)
                                                   const srCHAR * szFmtDescr, ...)
</source>
</source>


Line 232: Line 227:
| '''Type'''
| '''Type'''
| '''Description'''
| '''Description'''
|-
| tParent
| Input
| Handle to the parent test suite to which new annotation is to be added. srTEST_SUITE_DEFAULT can be used for the default test suite.
|-
|-
| eLevel
| eLevel
| Input  
| Input  
| Annotation level. Cannot be empty.
| Annotation level.  


* srTEST_ANNOTATION_LEVEL_TRACE,
* srTEST_ANNOTATION_LEVEL_TRACE,
Line 250: Line 241:
| szName  
| szName  
| Input  
| Input  
| Pointer to a null-terminated string that represents the name of annotation. If null, the default host naming scheme will be used.
| Pointer to a null-terminated string representing the name of the new annotation. If null, the default host naming scheme will be used.
|-
|-
| szDescr
| szFmtDescr
| Input  
| Input  
| Pointer to a null-terminated string representing the description of annotation. If null, description will be empty.
| Pointer to a null-terminated string representing the description of the new annotation. Cannot be null.
|-
| ...
| Input (Optional)
| Variable argument list to format szFmtDescr.
|}
|}
<br>
<br>
Line 262: Line 257:
|-
|-
| srTestAnnotationHandle_t  
| srTestAnnotationHandle_t  
| Handle of the newly created annotation. srTEST_ANNOTATION_INVALID indicates failure to create annotation.
| Handle of the newly created test annotation. srTEST_ANNOTATION_INVALID indicates failure to create a test annotation.
|}
|}


Line 275: Line 270:
     sprintf(szName, "annotation %d", count);
     sprintf(szName, "annotation %d", count);
     srTestAnnotationHandle_t annot =  
     srTestAnnotationHandle_t annot =  
                     srTestSuiteAddAnnotation(srTEST_SUITE_DEFAULT,
                     srTestSuiteAddAnnotation(srTEST_ANNOTATION_LEVEL_ERROR,
                                              srTEST_ANNOTATION_LEVEL_ERROR,
                                               szName,
                                               szName,
                                               "description of annotation");
                                               "description of annotation");
Line 287: Line 281:
</source>
</source>


==== srTestCaseSetName ====
 
The srTestCaseSetName() routine is used to set set the name of the specified test case.
==== srTestSuiteSetData ====
The srTestSuiteSetData() routine is used to associate a custom name|value pair with a test suite.
<source lang=c>
<source lang=c>
srWORD srTestCaseSetName(srTestCaseHandle_t tTestCase, const srCHAR *szName)
srWORD srTestSuiteSetData(const srCHAR * szName, const srCHAR * szFmtValue, ...)
</source>
</source>


Line 298: Line 293:
| '''Description'''
| '''Description'''
|-
|-
| tTestCase
| szName
| Input
| Input
| Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
| Pointer to a null-terminated string representing the name of the custom pair. Cannot be null.
|-
|-
| szName
| szFmtValue
| Input  
| Input  
| Pointer to a null-terminated string representing the name of test case. Cannot be null.
| Pointer to a null-terminated string representing the value of the custom pair. Cannot be null.
|}
<br>
{| border="1" cellspacing="0" cellpadding="10" style="align:left;"
| '''Return Value'''
| ''' Description'''
|-
|-
| srOK
| ...  
| Success
| Input (Optional)
|-
| Variable argument list to format szFmtValue.
| srERR
| Null string passed in.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
 
<source lang=c>
#include <srtest.h>
 
void tfcase_setName(void)
{
  srTestCaseSetName(srTEST_CASE_DEFAULT, "Setting name for default case");
}
 
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setName)
#endif
</source>
 
==== srTestCaseSetDescription ====
The srTestCaseSetDescription() routine is used to set the description of the specified test case.
<source lang=c>
srWORD srTestCaseSetDescription(srTestCaseHandle_t tTestCase, const srCHAR * szDescr)
</source>
 
{| border="1" cellspacing="0" cellpadding="10" style="align:left;" 
| '''Parameters'''
| '''Type'''
| '''Description'''
|-
| tTestCase
| Input
| Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
|-
| szDescr
| Input
| Pointer to a null-terminated string representing the description of test case. Cannot be null.
|}
|}
<br>
<br>
Line 361: Line 310:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srWORD
| Success
| srOK on success, srERR_HANDLE_INVALID on invalid handle.
|-
| srERR
| Null string passed in.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
|}


Line 377: Line 317:
#include <srtest.h>
#include <srtest.h>


void tfcase_setDescription(void)
void tfcase_setData(void)
{
{
   srTestCaseSetDescription(srTEST_CASE_DEFAULT,
   srTestSuiteSetData("MyName",
                           "Setting description for default case");
                           "my value");
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setDescription)
#pragma scl_test_flist("testfunc", tfcase_setData)
#endif
#endif
</source>
</source>
Line 421: Line 361:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srWORD
| Success
| srOK on success, srERR_HANDLE_INVALID on invalid handle.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|}
|}


Line 473: Line 410:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srWORD
| Success
| srOK on success, srERR_HANDLE_INVALID on invalid handle.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|}
|}


Line 493: Line 427:
</source>
</source>


==== srTestCaseAddComment ====
==== srTestCaseAddAnnotation ====
The srTestCaseAddComment() routine is used to add a comment (aka a log) to be reported with the specified test case.
The srTestCaseAddAnnotation() routine is used to add a new annotation to the specified test case.
<source lang=c>
<source lang=c>
srWORD srTestCaseAddComment(srTestCaseHandle_t tTestCase, const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
srTestAnnotationHandle_t srTestCaseAddAnnotation(rTestCaseHandle_t tTestCase, srTestAnnotationLevel_e eLevel, const srCHAR * szName, const srCHAR * szFmtDescr, ...)
</source>
</source>


Line 506: Line 440:
| tTestCase  
| tTestCase  
| Input
| Input
| Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
| Handle to the parent test case to which new test annotation is to be added. srTEST_CASE_DEFAULT can be used for the default test case.
|-
| eLevel
| Input
| Annotation level.
 
* srTEST_ANNOTATION_LEVEL_TRACE,
* srTEST_ANNOTATION_LEVEL_DEBUG,
* srTEST_ANNOTATION_LEVEL_INFO,
* srTEST_ANNOTATION_LEVEL_WARN,
* srTEST_ANNOTATION_LEVEL_ERROR,
* srTEST_ANNOTATION_LEVEL_FATAL
|-
|-
| szLabel
| szName
| Input
| Input  
| Pointer to a null-terminated string specifying the comment's label.
| Pointer to a null-terminated string representing the name of the new annotation. If null, the default host naming scheme will be used.
|-
|-
| szFmtComment
| szFmtDescr
| Input  
| Input  
| Pointer to a null-terminated string, which can be formatted, representing the comment. Cannot be null.
| Pointer to a null-terminated string representing the description of the new annotation. Cannot be null.
|-
|-
| ...  
| ...  
| Input (Optional)
| Input (Optional)
| Variable argument list to format the comment szFmtComment.
| Variable argument list to format szFmtDescr.
|}
|}
<br>
<br>
Line 525: Line 470:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srTestAnnotationHandle_t
| Success
| Handle of the newly created test annotation. srTEST_ANNOTATION_INVALID indicates failure to create a test annotation.
|-
| srERR
| Null string passed in.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
|}


Line 541: Line 477:
#include <srtest.h>
#include <srtest.h>


void tfcase_addComment(void)
void tfcase_addAnnotation(void)  
{
{
   srTestCaseAddComment(srTEST_CASE_DEFAULT, "Note",
   for (int count = 0; count < 5; ++count)
                      "this comment should print %s", "A STRING");
  {
    char szName[25];
    sprintf(szName, "annotation %d", count);
    srTestAnnotationHandle_t annot =
                    srTestCaseAddAnnotation(srTEST_CASE_DEFAULT,
                                            srTEST_ANNOTATION_LEVEL_ERROR,
                                            szName,
                                            "description of annotation");
  }
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_addComment)
#pragma scl_test_flist("testfunc", tfcase_addAnnotation)
#endif
#endif
</source>
</source>


==== srTestCaseAddAnnotation ====
==== srTestCaseSetData ====
The srTestCaseAddAnnotation() routine is used to add a new annotation to the specified test case.
The srTestCaseSetData() routine is used to associate a custom name|value pair with a test case.
<source lang=c>
<source lang=c>
srTestAnnotationHandle_t srTestCaseAddAnnotation(rTestCaseHandle_t tParent, srTestAnnotationLevel_e eLevel, const srCHAR * szName, const srCHAR * szDescr)
srWORD srTestCaseSetData(srTestCaseHandle_t tTestCase, const srCHAR * szName, const srCHAR * szFmtValue, ...);
</source>
</source>


Line 563: Line 507:
| '''Description'''
| '''Description'''
|-
|-
| tParent
| tTestCase
| Input
| Input
| Handle to the parent test case to which new annotation is to be added. srTEST_CASE_DEFAULT can be used for the default test case.
| Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
|-
|-
| eLevel
| szName
| Input  
| Input
| Annotation level. Cannot be empty.
| Pointer to a null-terminated string representing the name of the custom pair. Cannot be null.
 
* srTEST_ANNOTATION_LEVEL_TRACE,
* srTEST_ANNOTATION_LEVEL_DEBUG,
* srTEST_ANNOTATION_LEVEL_INFO,
* srTEST_ANNOTATION_LEVEL_WARN,
* srTEST_ANNOTATION_LEVEL_ERROR,
* srTEST_ANNOTATION_LEVEL_FATAL
|-
|-
| szName
| szFmtValue
| Input  
| Input  
| Pointer to a null-terminated string that represents the name of annotation. If null, the default host naming scheme will be used.
| Pointer to a null-terminated string representing the value of the custom pair. Cannot be null.
|-
|-
| szDescr
| ...
| Input  
| Input (Optional)
| Pointer to a null-terminated string representing the description of annotation. If null, description will be empty.
| Variable argument list to format szFmtValue.
|}
|}
<br>
<br>
Line 591: Line 528:
| ''' Description'''
| ''' Description'''
|-
|-
| srTestAnnotationHandle_t
| srWORD
| Handle of the newly created annotation. srTEST_ANNOTATION_INVALID indicates failure to create annotation.
| srOK on success, srERR_HANDLE_INVALID on invalid handle.
|}
|}


Line 598: Line 535:
#include <srtest.h>
#include <srtest.h>


void tfcase_addAnnotation(void)  
void tfcase_setData(void)
{
{
   for (int count = 0; count < 5; ++count)
   srTestCaseSetData(srTEST_CASE_DEFAULT, "MyName",
  {
                      "my value);
    char szName[25];
    sprintf(szName, "annotation %d", count);
    srTestAnnotationHandle_t annot =
                    srTestCaseAddAnnotation(srTEST_CASE_DEFAULT,
                                            srTEST_ANNOTATION_LEVEL_ERROR,
                                            szName,
                                            "description of annotation");
  }
}
}


#ifdef _SCL
#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_addAnnotation)
#pragma scl_test_flist("testfunc", tfcase_setData)
#endif
#endif
</source>
</source>


==== srTestAnnotationAddComment ====
==== srTestAnnotationAddComment ====
The srTestAnnotationAddComment() routine is used to add a comment (aka a log) to be reported with the specified annotation.
The srTestAnnotationAddComment() routine is used to add a comment (aka a log) to a test annotation.
<source lang=c>
<source lang=c>
srWORD srTestAnnotationAddComment(srTestAnnotationHandle_t tTestAnnotation, const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
srWORD srTestAnnotationAddComment(srTestAnnotationHandle_t tTestAnnotation, const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
Line 630: Line 559:
| tTestAnnotation
| tTestAnnotation
| Input
| Input
| Handle to an annotation created using srTestSuiteAddAnnotation.
| Handle to a test annotation.
|-
|-
| szLabel
| szLabel
Line 638: Line 567:
| szFmtComment  
| szFmtComment  
| Input  
| Input  
| Pointer to a null-terminated string, which can be formatted, representing the comment. Cannot be null.
| Pointer to a null-terminated string representing the new comment. Cannot be null.
|-
|-
| ...  
| ...  
| Input (Optional)
| Input (Optional)
| Variable argument list to format the comment szFmtComment.
| Variable argument list to format szFmtComment.
|}
|}
<br>
<br>
Line 649: Line 578:
| ''' Description'''
| ''' Description'''
|-
|-
| srOK
| srWORD
| Success
| srOK on success, srERR on null string or invalid formatted string, srERR_HANDLE_INVALID on invalid handle, srERR_STR_TRUNCATED on truncated string.
|-
| srERR  
| Null string passed in.
|-
| srTEST_ERR_HANDLE_INVALID
| Invalid handle passed in.
|-
| srTEST_WARN_STR_TRUNCATED
| String passed in was too large and was truncated.
|}
|}


Line 668: Line 588:
{
{
   srTestAnnotationHandle_t annot =  
   srTestAnnotationHandle_t annot =  
                           srTestSuiteAddAnnotation(srTEST_SUITE_DEFAULT,
                           srTestSuiteAddAnnotation(srTEST_ANNOTATION_LEVEL_ERROR,
                                                    srTEST_ANNOTATION_LEVEL_ERROR,
                                                     "annot",
                                                     "annot",
                                                     "annot description");
                                                     "annot description");

Revision as of 00:07, 2 August 2014

Runtime Test Services

The Runtime Test Services (declared in srtest.h) are a set of APIs in the STRIDE Runtime that facilitate the writing of target based test code. These APIs make up an optional portion of the STRIDE Runtime and can be used to communicate additional information about tests to the host based reporting mechanism. These APIs also allow target test code to create additional test suites and test cases dynamically at runtime.

There are two ways of accessing these APIs: through C-based functions, or through a C++ base class from which you may derive your C++ test class. These are discussed below in C Test Functions, and C++ Test Classes sections below.

Refer to the SCL Reference Guide or the Runtime Developer's Guide for more detailed information about any of these APIs.

C Test Functions

The following C APIs are provided:


C

srTestGetParam

The srTestGetParam() function is used to get the value of a named parameter as a string.

srWORD srTestGetParam(const srCHAR * szName, srCHAR * szValue, srDWORD dwSize, const srCHAR * szDefValue);
Parameters Type Description
szName Input Pointer to a null-terminated string that represents the name of the parameter. Cannot be null.
szValue Output Pointer to a block of memory to store the value of the parameter with a maximum size of dwSize chars
dwSize Input Size in chars of the buffer pointed to by szValue
szDefValue Input (optional) Pointer to a null-terminated string that represents a default value in case the parameter is not specified. By setting this value to srNULL (or omitting it), you can use srTestGetParam() to test for the existence of a named parameter. If the named parameter doesn't exist, the function will return srERR_HANDLE_INVALID.


Return Value Description
srOK Success
srERR Null or empty szName string passed in.
srERR_HANDLE_INVALID The named parameter is not found and szDefValue is set to srNULL.
#include <srtest.h>

#define MAX_VALUE_LEN 128
void tfsuite_getParam(void)
{
  srCHAR szValue[MAX_VALUE_LEN] = {0};

  srWORD wRet = srTestGetParam("ParamName", szValue, MAX_VALUE_LEN, "default value");
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif


srTestGetParamLong

The srTestGetParamLong() function is used to get the value of a named parameter as a long.

srLONG srTestGetParamLong(const srCHAR * szName, srLONG lDefValue);
Parameters Type Description
szName Input Pointer to a null-terminated string that represents the name of the parameter.
lDefValue Input Default value that is returned if the parameter is not found.


Return Value Description
srLONG Parameter value, or value specified by lDefValue if parameter isn't found.
#include <srtest.h>

void tfsuite_getParam(void)
{
  srLONG lVal = srTestGetParamLong("ParamName", -1);
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif

srTestGetParamDouble

The srTestGetParamDouble() function is used to get the value of a named parameter as a double.

double srTestGetParamDouble(const srCHAR * szName, double dbDefValue);
Parameters Type Description
szName Input Pointer to a null-terminated string that represents the name of the parameter.
dbDefValue Input Default value that is returned if the parameter is not found.


Return Value Description
double Parameter value, or value specified by dbDefValue if parameter isn't found.
#include <srtest.h>

void tfsuite_getParam(void)
{
  double dbVal = srTestGetParamDouble("ParamName", 0.5772156649);
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_getParam)
#endif

srTestSuiteAddCase

The srTestSuiteAddCase() routine is used to add a new test case to the specified test suite.

srTestCaseHandle_t srTestSuiteAddCase(const srCHAR * szName, const srCHAR * szDescr)
Parameters Type Description
szName Input Pointer to a null-terminated string that represents the name of the new test case. If null, the default host naming scheme will be used.
szDescr Input Pointer to a null-terminated string representing the description of the new test case. If null, description will be empty.


Return Value Description
srTestCaseHandle_t Handle of the newly created test case. srTEST_CASE_INVALID indicates failure to create a test case.
#include <srtest.h>
#include <stdio.h>

void tfsuite_addCase(void)
{
  for (int count = 0; count < 5; ++count)
  {
    char szName[25];
    sprintf(szName, "dynamic test case %d", count);
    srTestCaseHandle_t test = srTestSuiteAddCase(szName, "this is a dynamic test case");
    srTestCaseSetStatus(test, srTEST_PASS, 0); 
  }
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_addCase)
#endif

srTestSuiteAddAnnotation

The srTestSuiteAddAnnotation() routine is used to add a new annotation to the specified test suite.

srTestAnnotationHandle_t srTestSuiteAddAnnotation(srTestAnnotationLevel_e eLevel,
                                                  const srCHAR * szName, 
                                                  const srCHAR * szFmtDescr, ...)
Parameters Type Description
eLevel Input Annotation level.
  • srTEST_ANNOTATION_LEVEL_TRACE,
  • srTEST_ANNOTATION_LEVEL_DEBUG,
  • srTEST_ANNOTATION_LEVEL_INFO,
  • srTEST_ANNOTATION_LEVEL_WARN,
  • srTEST_ANNOTATION_LEVEL_ERROR,
  • srTEST_ANNOTATION_LEVEL_FATAL
szName Input Pointer to a null-terminated string representing the name of the new annotation. If null, the default host naming scheme will be used.
szFmtDescr Input Pointer to a null-terminated string representing the description of the new annotation. Cannot be null.
... Input (Optional) Variable argument list to format szFmtDescr.


Return Value Description
srTestAnnotationHandle_t Handle of the newly created test annotation. srTEST_ANNOTATION_INVALID indicates failure to create a test annotation.
#include <srtest.h>

void tfsuite_addAnnotation(void) 
{
  for (int count = 0; count < 5; ++count)
  {
    char szName[25];
    sprintf(szName, "annotation %d", count);
    srTestAnnotationHandle_t annot = 
                     srTestSuiteAddAnnotation(srTEST_ANNOTATION_LEVEL_ERROR,
                                              szName,
                                              "description of annotation");
  }
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuite_addAnnotation)
#endif


srTestSuiteSetData

The srTestSuiteSetData() routine is used to associate a custom name|value pair with a test suite.

srWORD srTestSuiteSetData(const srCHAR * szName, const srCHAR * szFmtValue, ...)
Parameters Type Description
szName Input Pointer to a null-terminated string representing the name of the custom pair. Cannot be null.
szFmtValue Input Pointer to a null-terminated string representing the value of the custom pair. Cannot be null.
... Input (Optional) Variable argument list to format szFmtValue.


Return Value Description
srWORD srOK on success, srERR_HANDLE_INVALID on invalid handle.
#include <srtest.h>

void tfcase_setData(void)
{
  srTestSuiteSetData("MyName",
                           "my value");
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setData)
#endif

srTestCaseSetStatus

The srTestCaseSetStatus() routine is used to set the result of test case.

srWORD srTestCaseSetStatus(srTestCaseHandle_t tTestCase, srTestStatus_e eStatus, srDWORD dwDuration)
Parameters Type Description
tTestCase Input Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
eStatus Input Result of the test. Possible values are:
  • srTEST_FAIL
  • srTEST_PASS
  • srTEST_NOTINUSE
  • srTEST_INPROGRESS
  • srTEST_DONE - applicable to dynamic cases - sets the status to pass unless already set to fail or not-in-use
dwDuration Input The duration of the test in clock ticks. Using "0" allows the STRIDE Runtime (Intercept Module) to set the time automatically.


Return Value Description
srWORD srOK on success, srERR_HANDLE_INVALID on invalid handle.
#include <srtest.h>

void tfcase_setStatus(void)
{
  srTestCaseSetStatus(srTEST_CASE_DEFAULT, srTEST_PASS, 0);
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setStatus)
#endif

srTestCaseSetStatusEx

The srTestCaseSetStatusEx() routine is used to set the result of test case and allow specification of an extendedFailureCode.

srWORD srTestCaseSetStatus(srTestCaseHandle_t tTestCase, srTestStatus_e eStatus, srDWORD dwDuration, srLONG lExtendedFailureCode)
Parameters Type Description
tTestCase Input Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
eStatus Input Result of the test.
dwDuration Input The duration of the test in clock ticks. Using "0" allows the STRIDE Runtime (Intercept Module) to set the time automatically.
lExtendedFailureCode Input The Stride framework uses the extendedFailureCode to capture the numeric results of test method when the test method fails via a numeric (non-void, nonbool) return type.


Return Value Description
srWORD srOK on success, srERR_HANDLE_INVALID on invalid handle.
#include <srtest.h>

void tfcase_setStatusEx(void)
{
  srTestCaseSetStatusEx(srTEST_CASE_DEFAULT, srTEST_FAIL, 0, -5);
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setStatusEx)
#endif

srTestCaseAddAnnotation

The srTestCaseAddAnnotation() routine is used to add a new annotation to the specified test case.

srTestAnnotationHandle_t srTestCaseAddAnnotation(rTestCaseHandle_t tTestCase, srTestAnnotationLevel_e eLevel, const srCHAR * szName, const srCHAR * szFmtDescr, ...)
Parameters Type Description
tTestCase Input Handle to the parent test case to which new test annotation is to be added. srTEST_CASE_DEFAULT can be used for the default test case.
eLevel Input Annotation level.
  • srTEST_ANNOTATION_LEVEL_TRACE,
  • srTEST_ANNOTATION_LEVEL_DEBUG,
  • srTEST_ANNOTATION_LEVEL_INFO,
  • srTEST_ANNOTATION_LEVEL_WARN,
  • srTEST_ANNOTATION_LEVEL_ERROR,
  • srTEST_ANNOTATION_LEVEL_FATAL
szName Input Pointer to a null-terminated string representing the name of the new annotation. If null, the default host naming scheme will be used.
szFmtDescr Input Pointer to a null-terminated string representing the description of the new annotation. Cannot be null.
... Input (Optional) Variable argument list to format szFmtDescr.


Return Value Description
srTestAnnotationHandle_t Handle of the newly created test annotation. srTEST_ANNOTATION_INVALID indicates failure to create a test annotation.
#include <srtest.h>

void tfcase_addAnnotation(void) 
{
  for (int count = 0; count < 5; ++count)
  {
    char szName[25];
    sprintf(szName, "annotation %d", count);
    srTestAnnotationHandle_t annot = 
                     srTestCaseAddAnnotation(srTEST_CASE_DEFAULT,
                                             srTEST_ANNOTATION_LEVEL_ERROR,
                                             szName,
                                             "description of annotation");
  }
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_addAnnotation)
#endif

srTestCaseSetData

The srTestCaseSetData() routine is used to associate a custom name|value pair with a test case.

srWORD srTestCaseSetData(srTestCaseHandle_t tTestCase, const srCHAR * szName, const srCHAR * szFmtValue, ...);
Parameters Type Description
tTestCase Input Handle to a test case. srTEST_CASE_DEFAULT can be used for the default test case.
szName Input Pointer to a null-terminated string representing the name of the custom pair. Cannot be null.
szFmtValue Input Pointer to a null-terminated string representing the value of the custom pair. Cannot be null.
... Input (Optional) Variable argument list to format szFmtValue.


Return Value Description
srWORD srOK on success, srERR_HANDLE_INVALID on invalid handle.
#include <srtest.h>

void tfcase_setData(void)
{
  srTestCaseSetData(srTEST_CASE_DEFAULT, "MyName",
                       "my value);
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfcase_setData)
#endif

srTestAnnotationAddComment

The srTestAnnotationAddComment() routine is used to add a comment (aka a log) to a test annotation.

srWORD srTestAnnotationAddComment(srTestAnnotationHandle_t tTestAnnotation, const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
Parameters Type Description
tTestAnnotation Input Handle to a test annotation.
szLabel Input Pointer to a null-terminated string for the label. If null, the default label will be applied.
szFmtComment Input Pointer to a null-terminated string representing the new comment. Cannot be null.
... Input (Optional) Variable argument list to format szFmtComment.


Return Value Description
srWORD srOK on success, srERR on null string or invalid formatted string, srERR_HANDLE_INVALID on invalid handle, srERR_STR_TRUNCATED on truncated string.
#include <srtest.h>

void tfsuiteAnnotation_addComment(void) 
{
  srTestAnnotationHandle_t annot = 
                           srTestSuiteAddAnnotation(srTEST_ANNOTATION_LEVEL_ERROR,
                                                    "annot",
                                                    "annot description");
  srTestAnnotationAddComment(annot,
                             srNULL,
                             "this comment should print %s", "A STRING");
}

#ifdef _SCL
#pragma scl_test_flist("testfunc", tfsuiteAnnotation_addComment)
#endif

C++ Test Classes

The Runtime Test Services C APIs work equally well from C test functions and C++ test classes. If, however, you are using C++ it might be more convinient for you to derive your C++ test classes from the Runtime Test Services C++ base class, srTest. That way you will have access to a set of simpler to use C++ classes.

The following C++ classes are provided:

class srTest

The srTest class provides two Member Objects:

  • testSuite of class srTestSuite
  • testCase of class srTestCase

class srTestSuite

The srTest class provides the folowing methods:

method SetName

The SetName method is used to set the name of test suite.

srWORD SetName(const srCHAR * szName)
Parameters Type Description
szName Input Pointer to null-terminated string representing the name of test suite. Cannot be empty.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_ERR_HANDLE_INVALID Invalid handle passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void suiteSetName()
  {
    testSuite.SetName("Setting name for suite");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method SetDescription

The SetDescription method is used to set the description of test suite.

srWORD SetDescription(const srCHAR * szDescr)
Parameters Type Description
szDescr Input Pointer to null-terminated string representing the description of test suite. Cannot be empty.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_ERR_HANDLE_INVALID Invalid handle passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void suiteSetDescription()
  {
    testSuite.SetDescription("Setting description for suite");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method AddSuite

The AddSuite[1] method is used to add a new test suite.

srTestSuite AddSuite(const srCHAR * szName = srNULL)
Parameters Type Description
szName Input (Optional) Pointer to null-terminated string that represents the name of test suite. If empty, the default host naming scheme will be used.


Return Value Description
srTestSuite Newly created test suite class.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void suiteAddSuite()
  {
    stride::srTestSuite suite = testSuite.AddSuite("tc Sub Suite");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method AddCase

The AddCase[1] method is used to add a new test case to test suite.

srTestCase AddCase(const srCHAR * szName = srNULL)
Parameters Type Description
szName Input (Optional) Pointer to null-terminated string that represents the name of test case. If empty, the default host naming scheme will be used.


Return Value Description
srTestCase Newly created test case class.


Example

#include <srtest.h>
#include <sstream>

class srtest_class : public stride::srTest
{
public:
  void suiteAddSuite()
  {
    const std::string prefix("dynamic test case ");
    for (int count = 0; count < 5; ++count)
    {
      std::stringstream strm;
      strm << prefix << count;
      stride::srTestCase tc = testSuite.AddCase(strm.str().c_str());
      tc.AddComment("this is a dynamic test case");
      tc.SetStatus(srTEST_PASS);
    }
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method AddAnnotation

The AddAnnotation method is used to add a new annotation to test suite.

srTestAnnotation AddAnnotation(srTestAnnotationLevel_e eLevel, const srCHAR * szName = srNULL, const srCHAR * szDescr = srNULL)
Parameters Type Description
eLevel Input Annotation level. Cannot be empty.
  • srTEST_ANNOTATION_LEVEL_TRACE,
  • srTEST_ANNOTATION_LEVEL_DEBUG,
  • srTEST_ANNOTATION_LEVEL_INFO,
  • srTEST_ANNOTATION_LEVEL_WARN,
  • srTEST_ANNOTATION_LEVEL_ERROR,
  • srTEST_ANNOTATION_LEVEL_FATAL
szName Input (Optional) Pointer to null-terminated string that represents the name of annotation. If empty, the default host naming scheme will be used.
szDescr Input (Optional) Pointer to null-terminated string that represents the description of annotation. If empty, the description will be blank.


Return Value Description
srTestAnnotation Newly created annotation class.
#include <srtest.h>
#include <sstream>

class srtest_class : public stride::srTest
{
public:
  void suiteAddAnnotation()
  {
    for (int count = 0; count < 5; ++count)
    {
      std::stringstream strmName;
      std::stringstream strmDescr;
      strmName << "annotation " << count;
      strmDescr << "description of annotation " << count;
      stride::srTestAnnotation ta = 
                 testSuite.AddAnnotation(srTEST_ANNOTATION_LEVEL_INFO,
                                         strmName.str().c_str(),
                                         strmDescr.str().c_str());
    }
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif

class srTestCase

The srTestCase class provides the following methods:

method SetName

The SetName method is used to set the name of test case.

srWORD SetName(const srCHAR * szName)
Parameters Type Description
szName Input Pointer to null-terminated string representing the name of test case. Cannot be empty.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_ERR_HANDLE_INVALID Invalid handle passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void caseSetName()
  {
    testCase.SetName("Setting name for case");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method SetDescription

The SetDescription method is used to set the description of test case.

srWORD SetDescription(const srCHAR * szDescr)
Parameters Type Description
szDescr Input Pointer to null-terminated string representing the description of test case. Cannot be empty.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_ERR_HANDLE_INVALID Invalid handle passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void caseSetDescription()
  {
    testCase.SetDescription("Setting description for case");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method SetStatus

The SetStatus method is used to set the result of the default test case.

srWORD SetStatus(srTestStatus_e eStatus, srDWORD dwDuration = 0)
Parameters Type Description
eStatus Input Result of the test. Possible values are:
  • srTEST_FAIL
  • srTEST_PASS
  • srTEST_NOTINUSE
  • srTEST_INPROGRESS
  • srTEST_DONE - applicable to dynamic cases - sets the status to pass unless already set to fail or not-in-use
dwDuration Input (Optional) The duration of the test in clock ticks. The default is 0.


Return Value Description
srOK Success
srTEST_ERR_HANDLE_INVALID Invalid handle.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void caseSetStatus()
  {
    testCase.SetStatus(srTEST_NOTINUSE, 0);
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method AddComment

The AddComment method is used to add a comment to test case.

srWORD AddComment(const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
Parameters Type Description
szLabel Input Pointer to a null-terminated string representing the comment label.
szFmtComment Input Pointer to null-terminated string, which can be formatted, representing the comment. Cannot be empty.
... Input (Optional) Variable argument list to format the comment szFmtComment.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void caseAddComment()
  {
    testCase.AddComment("this comment should print %s", "A STRING");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif
method AddAnnotation

The AddAnnotation method is used to add a new annotation to test case.

srTestAnnotation AddAnnotation(srTestAnnotationLevel_e eLevel, const srCHAR * szName = srNULL, const srCHAR * szDescr = srNULL)
Parameters Type Description
eLevel Input Annotation level. Cannot be empty.
  • srTEST_ANNOTATION_LEVEL_TRACE,
  • srTEST_ANNOTATION_LEVEL_DEBUG,
  • srTEST_ANNOTATION_LEVEL_INFO,
  • srTEST_ANNOTATION_LEVEL_WARN,
  • srTEST_ANNOTATION_LEVEL_ERROR,
  • srTEST_ANNOTATION_LEVEL_FATAL
szName Input (Optional) Pointer to null-terminated string that represents the name of annotation. If empty, the default host naming scheme will be used.
szDescr Input (Optional) Pointer to null-terminated string that represents the description of annotation. If empty, the description will be blank.


Return Value Description
srTestAnnotation Newly created annotation class.
#include <srtest.h>
#include <sstream>

class srtest_class : public stride::srTest
{
public:
  void caseAddAnnotation()
  {
    for (int count = 0; count < 5; ++count)
    {
      std::stringstream strmName;
      std::stringstream strmDescr;
      strmName << "annotation " << count;
      strmDescr << "description of annotation " << count;
      stride::srTestAnnotation ta = 
                 testCase.AddAnnotation(srTEST_ANNOTATION_LEVEL_INFO,
                                         strmName.str().c_str(),
                                         strmDescr.str().c_str());
    }
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif

class srTestAnnotation

The srTestAnnotation class provides the following methods:

method AddComment

The AddComment method is used to add a comment to an annotation created under a test suite.

srWORD AddComment(const srCHAR * szLabel, const srCHAR * szFmtComment, ...)
Parameters Type Description
szLabel Input Pointer to null-terminated string for the label. If null, the default label will be applied.
szFmtComment Input Pointer to null-terminated string, which can be formatted, representing the comment. Cannot be empty.
... Input (Optional) Variable argument list to format the comment szFmtComment.


Return Value Description
srOK Success
srERR Null string passed in.
srTEST_ERR_HANDLE_INVALID Invalid handle passed in.
srTEST_WARN_STR_TRUNCATED String passed in was too large and was truncated.
#include <srtest.h>

class srtest_class : public stride::srTest
{
public:
  void suiteAnnotationAddComment()
  {
    stride::srTestAnnotation ta = 
                 testSuite.AddAnnotation(srTEST_ANNOTATION_LEVEL_INFO,
                                         "annot",
                                         "annot description");
    ta.AddComment("this comment on annotation should print %s", "A STRING");
  }
};

#ifdef _SCL
#pragma scl_test_class(srtest_class)
#endif

Notes

  1. 1.0 1.1 Cite error: Invalid <ref> tag; no text was provided for refs named dynamic