Published on :
Test CREATION_INTERNE

Unit Tests for %mf_getapploc

This code is also available in: Deutsch Español Français
Awaiting validation
The script uses the `%mp_assert` macro to perform several assertions. Each assertion verifies that a call to `%mf_getapploc` with a specific path (e.g., `/some/loc/tests/services/x/service`) returns the expected application path (e.g., `/some/loc`). The tests cover different path scenarios including services, nested locations, jobs, and macros/tests without subfolders, ensuring that the `%mf_getapploc` extraction logic is robust. The assertion results are recorded in the `work.test_results` table.
Data Analysis

Type : CREATION_INTERNE


The data used for the tests (the input paths provided to `%mf_getapploc`) are generated directly in the code by macro calls. The test results are stored in an internally created temporary table (`work.test_results`).

1 Code Block
Macro calls %mp_assert Data
Explanation :
This block contains a series of calls to the `%mp_assert` macro. Each call is a unit assertion that checks if the `iftrue` expression is true. The `iftrue` expression compares the result of `%mf_getapploc` (with a specific input path) to an expected value. The test description (`desc`) and the output results table (`outds=work.test_results`) are provided for each assertion. These assertions test different use cases for `%mf_getapploc`, including service, job, and test folder paths, to validate its application path extraction logic.
Copied!
1%mp_assert(
2 iftrue=(
3 "%mf_getapploc(/some/loc/tests/services/x/service)"="/some/loc"
4 ),
5 desc=Checking test appLoc matches,
6 outds=work.test_results
7)
8 
9%mp_assert(
10 iftrue=(
11 "%mf_getapploc(/some/loc/tests/services/tests/service)"="/some/loc"
12 ),
13 desc=Checking nested services appLoc matches,
14 outds=work.test_results
15)
16 
17%mp_assert(
18 iftrue=(
19 "%mf_getapploc(/some/area/services/admin/service)"="/some/area"
20 ),
21 desc=Checking services appLoc matches,
22 outds=work.test_results
23)
24 
25%mp_assert(
26 iftrue=(
27 "%mf_getapploc(/some/area/jobs/jobs/job)"="/some/area"
28 ),
29 desc=Checking jobs appLoc matches,
30 outds=work.test_results
31)
32 
33%mp_assert(
34 iftrue=(
35 "%mf_getapploc(/some/area/tests/macros/somemacro.sas)"="/some/area"
36 ),
37 desc=Checking tests/macros appLoc matches (which has no subfolder),
38 outds=work.test_results
39)
40 
41%mp_assert(
42 iftrue=(
43 "%mf_getapploc(/some/area/tests/testsetup)"="/some/area"
44 ),
45 desc=Checking tests/testsetup operation,
46 outds=work.test_results
47)
48 
49%mp_assert(
50 iftrue=(
51 "%mf_getapploc(/some/area/tests/testteardown)"="/some/area"
52 ),
53 desc=Checking tests/teardown operation,
54 outds=work.test_results
55)
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/.