prj/run-tests.sh
param | description |
---|---|
lib |
for the libs tests |
macro |
for the macro test |
or any other test label (see below)
please note that "param" is a comma-delimited list
ENTANDO_OPT_LOG_LEVEL=DEBUG prj/run-tests.sh macro
A test label is a comment like this
#TEST:lib
placed just before the function to run as part of the test
The testing process creates a temporary dir in which the test is executed. Furthermore defines environment variable defaults, deploys some fixtures and mocks some resources by operating on the enviroment variables.
The script provides two mocked repositories that can be referenced through these variables:
ENTANDO_OPT_REPO_BOM_URL
: (local) url of the mock of the BOM repositoryPPL_CLONE_URL
: (local) url of the mock of an example module repository
var | description |
---|---|
TEST__EXECUTION |
set to true during the test runs |
PROJECT_DIR |
the path of the project from which the test was run |
TEST__WORK_DIR |
the (temporary) working directory of the current test run |
FAIL {reason}
Stop the test execution with an error
ASSERT {VAR} {OP} {EXPECTED-VALUE}
Expects the VAR
value to match the EXPECTED-VALUE
according with OP
ASSERT -v {VALUE-DESC} {VALUE} {OP} {EXPECTED-VALUE}
Expects VALUE
to match EXPECTED-VALUE
according with OP
.
The VALUE-DESC
is used instead of VAR-NAME
in order to compose the error message.
operator type | operators list |
---|---|
Numerical | -eq ,-ne ,-gt ,-ge ,-lt ,-le |
General | = or == ,!= |
Regexp | =~ |
Regexp negated (custom) | !=~ |
Refer to the bash "IF" documentation for details
Drops a debug shell.
Put it in the middle of a test to drop a shell with all the execution environment available, including the temporary test work dir, variables and functions.
Define this function in order to customize the test environment
Example:
TEST__BEFORE_RUN() {
GIT_USER_NAME="Test Bot"
GIT_USER_EMAIL="[email protected]"
PPL_CONTEXT="$(cat "$PROJECT_DIR/test/resources/my-context.json")"
}
Define this function in order to override the execution environment variables just after the pipeline context is parsed.
Example:
TEST__APPLY_OVERRIDES() { PPL_PR_TITLE="A-MOCKED-PR-TITLE"; }
if set to true a DBGSHELL is dropped when a test asserts
Examples:
ENTANDO_OPT_LOG_LEVEL=DEBUG ENTANDO_OPT_SHELL_ON_TEST_ASSERT=true prj/run-tests.sh macro
If non-empty it's used as regex to recognize and mark the errors that were actually expected to happen.