The script does not consume unmanaged external data. It creates a log configuration template file in the temporary 'WORK' library and uses a reference path (g_refdata) which is a SASUnit macro variable supposed to point to test data managed by the framework.
1 Code Block
SASUnit Macro
Explanation : Initializes the global test scenario and defines the 'testcase' macro that encapsulates the unit test logic. The 'i_desc' parameter provides a description of the scenario, identifying the objective of the test.
Copied!
%initScenario (i_desc=Test of _createScnLogConfigTemplate.sas);
%macro testcase(i_object=_createScnLogConfigTemplate.sas, i_desc=%str(Correct call));
1
%initScenario (i_desc=Test of _createScnLogConfigTemplate.sas);
Explanation : This block initializes the specific test case and calls the `_createScnLogConfigTemplate` macro. This macro is tested to ensure it correctly generates a SASUnit log configuration file. The file is created in the SAS working folder (`WORK`) with the name `sasunit.scnlogconfig.xx.template.xml`. Log folder paths and language are specified, with 'XX' being a placeholder for the test.
Explanation : This block contains the assertions that verify the success of the test. `%assertLog` ensures that no warnings or errors were issued in the SAS log. `%assertEquals` verifies that the template file was indeed created using the `fileexist` function. `%assertText` compares the content of the generated file with a reference file specified by the `g_refdata` macro variable to validate its conformity.
Copied!
/* assert */
%assertLog(i_errors=0, i_warnings=0);
%assertEquals (i_actual =%sysfunc(fileexist(%sysfunc(pathname(WORK))/sasunit.scnlogconfig.xx.template.xml))
,i_expected=1
,i_desc =New scn log config template xml file must exist
);
%assertText (i_expected = &g_refdata./sasunit.scnlogconfig.xx.template.xml
,i_actual = %sysfunc(pathname(WORK))/sasunit.scnlogconfig.xx.template.xml
,i_desc = Scn-Log config template created correctly
);
/* end testcase */
%endTestcase()
,i_desc = Scn-Log config template created correctly
11
);
12
13
/* end testcase */
14
%endTestcase()
4 Code Block
SYSCALL Function / Cleanup
Explanation : This block handles cleanup after the test. It defines a fileref `fdel` pointing to the created template file, then uses `%sysfunc(fdelete(fdel))` to delete this file. `filename fdel clear;` releases the fileref. The final lines (`%mend testcase; %testcase; %endScenario();`) mark the end of the test macro and the global SASUnit scenario.
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.