This script aims to verify the correct functioning of the _executeCmdFile macro. It proceeds by dynamically creating a system script (.cmd file) in the temporary WORK directory which contains an instruction to create a 'TestFolder' directory. The macro is then called to execute this script. The test concludes with an assertion verifying that the folder has indeed been created.
Data Analysis
Type : INTERNAL_CREATION
The script generates its own test files (.cmd file) directly in the code via a Data Step.
1 Code Block
MACRO
Explanation : Initialization of the SASUnit test scenario.
Copied!
%initScenario (i_desc=Test of _executeCmdFile.sas)
1
%initScenario (i_desc=Test of _executeCmdFile.sas)
2 Code Block
DATA STEP Data
Explanation : Retrieval of the WORK directory path and creation of a system command file (.cmd) containing the instruction to create a folder named 'TestFolder'.
Copied!
%let path = %sysfunc (pathname(WORK));
data _null_;
file "&path./createfolder.cmd";
put "&g_makedir. ""&path./TestFolder""";
run;
1
%let path = %sysfunc (pathname(WORK));
2
DATA _null_;
3
file "&path./createfolder.cmd";
4
put "&g_makedir. ""&path./TestFolder""";
5
RUN;
3 Code Block
MACRO
Explanation : Initialization of the test case and execution of the _executeCmdFile macro pointing to the previously created command file.
Copied!
%initTestcase(i_object=_executeCmdFile.sas, i_desc=check call of program)
%_executeCmdFile(&path./createfolder.cmd);
%endTestCall;
1
%initTestcase(i_object=_executeCmdFile.sas, i_desc=check call of program)
2
3
%_executeCmdFile(&path./createfolder.cmd);
4
5
%endTestCall;
4 Code Block
MACRO
Explanation : Verification of results: ensuring that the 'TestFolder' directory exists (expected value 1) and validating the logs before closing the test case and the scenario.
Copied!
%assertEquals(i_expected=1, i_actual=%_existdir(&path./TestFolder), i_desc=Folder should exist)
%assertLog()
%endTestcase()
%endScenario();
1
%assertEquals(i_expected=1, i_actual=%_existdir(&path./TestFolder), i_desc=Folder should exist)
2
%assertLog()
3
%endTestcase()
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
Related Documentation
Aucune documentation spécifique pour cette catégorie.
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.