This script does not manipulate data in the traditional sense (SAS tables). It generates test conditions and verifies the content of the SAS log. The error message is internal test data generated by the script itself.
1 Code Block
SASUnit Macro Execution
Explanation : Initializes a new test scenario within the SASUnit framework with a specified description. This macro prepares the environment for a series of test cases.
Copied!
%initScenario (i_desc=Test of _issueasserterrormessage.sas);
1
%initScenario (i_desc=Test of _issueasserterrormessage.sas);
2
2 Code Block
SASUnit Macro Execution
Explanation : This block defines and invokes the `testcase` macro. This macro configures a specific test environment by activating the global variable `g_UseLog4SAS` to potentially use Log4SAS, initializes a SASUnit test case, calls the `_issueasserterrormessage` macro with an error message, then uses SASUnit assertions (`%assertLog`, `%assertLogMsg`) to verify that the call generated a unique error in the log and that the error message matches the expected one. The macro definition is included as it encapsulates the complete logic of the test case.
Copied!
%macro testcase(i_object=_issueasserterrormessage.sas, i_desc=%str(Call with logging level Info, which is default));
/*****************
documentation
******************
setup [...]
call [...]
assert [...]
*****************/
%let g_UseLog4SAS = 1;
/* start testcase */
%initTestcase(i_object=&i_object., i_desc=&i_desc.);
/* call */
%_issueasserterrormessage(Dies ist meine Fehlermeldung!);
%endTestcall()
/* assert */
%assertLog (i_errors=1, i_warnings=0);
%assertLogMsg (i_logMsg=^ERROR: Dies ist meine Fehlermeldung!);
/* end testcase */
%endTestcase()
%mend testcase; %testcase;
1
%macro testcase(i_object=_issueasserterrormessage.sas, i_desc=%str(Call with logging level Info, which is default));
%_issueasserterrormessage(Dies ist meine Fehlermeldung!);
17
18
%endTestcall()
19
20
/* assert */
21
%assertLog (i_errors=1, i_warnings=0);
22
%assertLogMsg (i_logMsg=^ERROR: Dies ist meine Fehlermeldung!);
23
24
/* end testcase */
25
%endTestcase()
26
%mend testcase; %testcase;
3 Code Block
SASUnit Macro Execution
Explanation : Ends the SASUnit test scenario, consolidating the results of all test cases executed within this scenario.
Copied!
%endScenario();
1
%endScenario();
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Copyright 2010-2023 HMS Analytical Software GmbH, http://www.analytical-software.de This file is part of SASUnit, the Unit testing framework for SAS(R) programs. For copyright information and terms of usage under the GNU Lesser General Public License see included file README.md or https://github.com/HMS-Analytical-Software/SASUnit/wiki/readme/.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.