Published on :
Test CREATION_INTERNE

Test of the _issueasserterrormessage macro

This code is also available in: Français Deutsch Español
The script uses the SASUnit framework to create a test scenario. It defines a single test case that initializes the test, enables Log4SAS© logging (`g_UseLog4SAS© = 1`), then calls the `_issueasserterrormessage` macro with a specific error message ('Dies ist meine Fehlermeldung!'). Finally, it uses SASUnit assertions (`%assertLog`, `%assertLogMsg`) to verify that the log contains exactly one error and that the generated error message is indeed the one expected by the test.
Data Analysis

Type : CREATION_INTERNE


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!
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!
1%macro testcase(i_object=_issueasserterrormessage.sas, i_desc=%str(Call with logging level Info, which is default));
2 /*****************
3 documentation
4 ******************
5 setup [...]
6 call [...]
7 assert [...]
8 *****************/
9 
10 %let g_UseLog4SAS = 1;
11
12 /* start testcase */
13 %initTestcase(i_object=&i_object., i_desc=&i_desc.);
14 
15 /* call */
16 %_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!
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/.