SASUnit Examples  Version 1.2
inittestcase.sas
Go to the documentation of this file.
1 
32 /* change log
33  29.01.2013 KL changed link from _sasunit_doc.sas to Sourceforge SASUnit User's Guide
34  02.01.2013 KL To support LINUX as OS we need to convert pgm-names (macro names) to lowercase. Otherwise LINUX can't find the macro and assigns no pgm-library.
35  09.02.2011 KL added two macro variables for re-redirecting log- and printfile in testcases
36 */
37 
38 %MACRO initTestcase(
39  i_object =
40  ,i_desc =
41  ,i_specdoc =
42 );
43 
44 %GLOBAL g_inTestcase;
45 %IF &g_inTestcase EQ 1 %THEN %DO;
46  %endTestcall;
47  %endTestcase;
48 %END;
49 %IF &g_inTestcase EQ 2 %THEN %DO;
50  %endTestcase;
51 %END;
52 %LET g_inTestcase=1;
53 
54 /* handle absolute and relative paths for programs */
55 %LOCAL l_pgm l_auton l_object;
56 %LET l_object = %lowcase (&i_object.);
57 %IF %index(%sysfunc(translate(&l_object,/,\)),/) %THEN %DO;
58  %LET l_pgm = %_sasunit_stdPath(&g_root,&i_object);
59  %LET l_auton=.;
60 %END;
61 %ELSE %DO;
62  %LET l_pgm = &i_object;
63  %LET l_auton = %_sasunit_getAutocallNumber(&l_object);
64 %END;
65 
66 /* determine next test case id */
67 %LOCAL l_casid;%LET l_casid=0;
68 PROC SQL NOPRINT;
69  SELECT max(cas_id) INTO :l_casid FROM target.cas
70  WHERE cas_scnid = &g_scnid;
71 %IF &l_casid=. %THEN %LET l_casid=1;
72 %ELSE %LET l_casid=%eval(&l_casid+1);
73 /* save metadata for this test case */
74  INSERT INTO target.cas VALUES (
75  &g_scnid
76  ,&l_casid
77  ,&l_auton
78  ,"&l_pgm"
79  ,"&i_desc"
80  ,"%_sasunit_abspath(&g_doc,&i_specdoc)"
81  ,%sysfunc(datetime())
82  ,.
83  ,.
84  );
85 QUIT;
86 
87 %PUT ========================== test case &l_casid ======================================================;
88 
89 /* reroute SASLOG and SASLIST */
90 %LET g_logfile =&g_log/%sysfunc(putn(&g_scnid,z3.))_%sysfunc(putn(&l_casid,z3.)).log;
91 %LET g_printfile=&g_testout/%sysfunc(putn(&g_scnid,z3.))_%sysfunc(putn(&l_casid,z3.)).lst;
92 PROC PRINTTO
93  NEW
94  LOG="&g_logfile."
95  PRINT="&g_printfile."
96 ;
97 RUN;
98 
99 %MEND initTestcase;