SASUnit Examples  Version 1.5.0
_getscenariotestid.sas
Go to the documentation of this file.
1 
24 %macro _getScenarioTestId (i_scnid=
25  ,r_casid=
26  ,r_tstid=
27  );
28 
29  %LOCAL l_casid_gti l_tstid_gti;
30 
31  %*** Set return variable to missing, the designed value for an error ***;
32 
33  %IF %nrbquote (&i_scnid.) eq %THEN %DO;
34  %PUT &g_error.(SASUNIT): Please specify a value for i_scnid.;
35  %RETURN;
36  %END;
37 
38  %IF %nrbquote (&r_casid.) eq %THEN %DO;
39  %PUT &g_error.(SASUNIT): Please specify a value for r_casid.;
40  %RETURN;
41  %END;
42 
43  %IF %nrbquote (&r_tstid.) eq %THEN %DO;
44  %PUT &g_error.(SASUNIT): Please specify a value for r_tstid.;
45  %RETURN;
46  %END;
47 
48  %IF not %symexist(&r_casid.) %THEN %DO;
49  %PUT &g_error.(SASUNIT): Macrovariable for return of test case id was not declared by a %nrstr(%%)local-statement.;
50  %RETURN;
51  %END;
52  %let &r_casid.=_ERROR_;
53 
54  %IF not %symexist(&r_tstid.) %THEN %DO;
55  %PUT &g_error.(SASUNIT): Macrovariable for return of test assert id was not declared by a %nrstr(%%)local-statement.;
56  %RETURN;
57  %END;
58  %let &r_tstid.=_ERROR_;
59 
60  %IF not %sysfunc (exist (target.cas)) %THEN %DO;
61  %PUT &g_error.(SASUNIT): Table target.cas does not exist. Start this macro only within SASUnit.;
62  %RETURN;
63  %END;
64 
65  %IF not %sysfunc (exist (target.tst)) %THEN %DO;
66  %PUT &g_error.(SASUNIT): Table target.tst does not exist. Start this macro only within SASUnit.;
67  %RETURN;
68  %END;
69 
70  PROC SQL NOPRINT;
71  *** determine number of the current test case ****;
72  SELECT max(cas_id) INTO :l_casid_gti FROM target.cas WHERE cas_scnid = &i_scnid.;
73  QUIT;
74 
75  %IF &l_casid_gti = . OR &l_casid_gti = %THEN %DO;
76  %PUT &g_error.(SASUNIT): Scenario was not found in the test database.;
77  %PUT &g_error.(SASUNIT): Assert may not be called prior to initTestcase.;
78  %RETURN;
79  %END;
80 
81  PROC SQL NOPRINT;
82  *** determine number of the current test case ****;
83  SELECT max(tst_id) INTO :l_tstid_gti FROM target.tst WHERE tst_scnid = &i_scnid. AND tst_casid=&l_casid_gti.;
84  QUIT;
85  %IF &l_tstid_gti.=. %THEN %LET l_tstid_gti=1;
86  %ELSE %LET l_tstid_gti=%eval (&l_tstid_gti.+1);
87 
88  %let &r_casid.=&l_casid_gti.;
89  %let &r_tstid.=&l_tstid_gti.;
90 %mend _getScenarioTestId;