Published on :
Test INTERNAL_CREATION

Test of _issueassertwarningmessage.sas

This code is also available in: Français Deutsch
This script uses the SASUnit testing framework to validate the behavior of the `_issueassertwarningmessage.sas©` macro. It defines a test scenario (`%initScenario`), then a unique test case encapsulated within a macro (`%macro testcase`). In this test case, the `_issueassertwarningmessage` macro is called with a specific character string ('Dies ist meine Warnmeldung!'). Subsequently, the test checks the SAS© log using `%assertLog` to ensure that no errors are present and that exactly one warning has been generated. `%assertLogMsg` is used to confirm that the warning contains the expected message. Finally, the `testcase` macro is called to execute the test, and the scenario is ended by `%endScenario`.
Data Analysis

Type : INTERNAL_CREATION


The script does not directly manipulate external data or data from `SASHELP`. It uses internal data (a literal warning message) to test the behavior of a SASUnit macro. The SASUnit framework itself manages the configuration of logs and assertions necessary for test execution.

1 Code Block
SASUnit Initialization / Macro Definition
Explanation :
This block initializes a SASUnit test scenario with a clear description. It then defines a macro named `testcase` which will serve as a wrapper for the test logic. The `i_object` and `i_desc` parameters of this macro are used to specify the tested object and a contextual description of the test case.
Copied!
1%initScenario (i_desc=Test of _issueassertwarningmessage.sas);
2%macro testcase(i_object=_issueassertwarningmessage.sas, i_desc=%str(Correct call of examinee));
3 
2 Code Block
Macro Call / SASUnit Assertions
Explanation :
This block, contained within the `testcase` macro, initializes the specific test case. It calls the `_issueassertwarningmessage` macro with a literal warning message in German. After the execution of this macro, the test proceeds with assertions: `%assertLog` verifies that no error messages are present in the log and that exactly one warning has been issued. `%assertLogMsg` then confirms that the specific text of the expected warning is present in the log.
Copied!
1 /*****************
2 documentation
3 ******************
4 setup [...]
5 call [...]
6 assert [...]
7 *****************/
8 
9 /* start testcase */
10 %initTestcase(i_object=&i_object., i_desc=&i_desc.);
11 
12 /* call */
13 %_issueassertwarningmessage(Dies ist meine Warnmeldung!);
14 
15 %endTestcall()
16 
17 /* assert */
18 %assertLog (i_errors=0, i_warnings=1);
19 %assertLogMsg (i_logMsg=^WARNING: Dies ist meine Warnmeldung!);
3 Code Block
Macro End / Test Execution / Scenario End
Explanation :
This block marks the end of the `testcase` macro definition and its test case (`%endTestcase`, `%mend testcase`). Immediately after, the `testcase` macro is invoked (`%testcase;`) to execute the test. Finally, `%endScenario()` closes the entire SASUnit test scenario.
Copied!
1 /* end testcase */
2 %endTestcase()
3%mend testcase; %testcase;
4 
5%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/.