This repository contains real-world test artifacts along with test models that are used to verify on-device decisioning functionality within each Adobe Target SDK ( AKA the "test schema" ).
The test schema files reside within the schema folder of this repo. There are two folders inside that will be of interest in testing:
| Folder | Description |
|---|---|
| schema/artifacts | Contains a series of json files representing artifacts that are used when testing various on-device decisioning scenarios. |
| schema/models | Contains a series of json files, each one describing a suite of tests to run along with the artifact, config, input and expected outputs. |
In order to use these test files you need to reference the schema folder of this repo within a specific target SDK repo. This is done via git subtree. And there is a script for you to use that makes the process very simple.
Follow these steps to establlish the git subtree for the first time.
- Download the updateTestSchema.sh file from this repo into the target SDK.
- Edit
updateTestSchema.shand change theTEST_SCHEMA_DESTINATION_FOLDERvariable to the path for where you want theschemafolder to live within the target SDK repo. - Set file permissions to execute:
chmod +x updateTestSchema.sh - Execute the script from the repo root folder:
./updateTestSchema.sh
To update to the latest test schema, simply execute the src/updateTestSchema.sh script at any time.
./updateTestSchema.shTo use the schema, you will need to create a test that reads the test suite files, and dynamically instruments tests based on the definitions.
- When the test begins, it lists the
.jsonfiles withinschema/models. EachTEST_SUITE_XXXXXX.jsonfile represents a suite of tests to execute. - Each
TEST_SUITE_XXXXXX.jsonfile is read and parsed. - The json tree within
TEST_SUITE_XXXXXX.jsonis traversed, looking for properties namedartifactwith a value that begins withTEST_ARTIFACT_. In every case, the artifact value is then replaced with the json content of the corresponding artifact in theschema/artifactsfolder. For example, ifschema/models/TEST_SUITE_AB_SIMPLE.jsonhas anartifactproperty set toTEST_ARTIFACT_AB_SIMPLE, then the contents ofschema/artifacts/TEST_ARTIFACT_AB_SIMPLE.jsonreplaces the value forartifact.
For each test suite file...
- Setup mocks
- The request for the artifact must be mocked so that the
artifactspecified for the suite is returned when the SDK requests it. If anartifactis specified in the test itself, use it instead. - Mock the geo response if a
mockGeoobject is specified in the test. - Lock the system date to the
mockDateif one is specified for the test.
- The request for the artifact must be mocked so that the
- Initialize the SDK using the
confobject from the suite. If aconfis specified in the test itself, use it instead. - Make a
getOfferscall, passing in theinputobject specified in the test. - Validate
- Validate the result from the
getOfferscall contains the keys and values specified within theoutputobject. - If
notificationOutputis specified within the test, validate that a notification was sent and that it contains the keys and values specified withinnotificationOutput. IfnotificationOutputis null, verify that no notifications were sent.
- Validate the result from the
To see a working example check out the Node.js test runner
To add additional tests to the suite:
- Create a new activity in the
Target Testingadmin here - Find the object that contains the
artifactFilenameyou wish to update insrc/testArtifacts.json. UpdateactivityIdsandadminUrlswith the activity ID and admin URL of the new activity - Follow the steps below to update the artifacts located at
src/schema.artifactswith the new activity - Update the corresponding test model located at
src/schema/modelswith the new activity by following these steps. Specifications for the test models can be found here - Update the On-device decisioning test artifact wiki to include the new activity created in the appropriate table with details.
The schema/models/TEST_SUITE_XXXXXX.json files have the following properties.
| property | description |
|---|---|
| description | A brief description of the test suite. |
| artifact | A string referencing an artifact file within schema/artifacts without the file extension. This artifact is to be used for each test defined within the suite, unless artifact is specified in the test itself. |
| conf | An object with configuration values that will be passed into the SDK initialization during the test. |
| test | An object with key values where the key is a unique idenifier for the test and the value is a json object with additional details for the specific test. |
Each test object may have the following properties.
| property | required | description |
|---|---|---|
| artifact | NO | Same as above, but not always specified. It is used to override the artifact set at the suite level, which is necessary for some tests. |
| conf | NO | Same as above, but not always specified. It is used to override the configuration set at the suite level, which is necessary for some tests. |
| description | YES | A brief description of the test. |
| input | YES | An object representing the Target Delivery Request passed in to a getOffers call. |
| output | YES | An object representing the expected Target Delivery Response from a getOffers call. It specifies properties that must be present and validated. Some properties are excluded if they are irrelevant to the test. |
| notificationOutput | NO | An object representing the expected notification output. Used to validate notification payloads when making execute requests. Not always present. |
| mockDate | NO | An object indicating a specific date to lock the test to (year, month, date, hours). Used in some tests to override the system date used during runtime. |
| mockGeo | NO | An object indicating a geo payload as would be received from /v1/geo. If present, the test needs to use it to mock any requests made to that endpoint. |
The test artifacts are generated from a real production artifact. This artifact belongs to the following test organization.
| Property | Value |
|---|---|
| clientId | targettesting |
| organizationId | 74F652E95F1B16FE0A495C92@AdobeOrg |
| environment | production |
More details about the specific Target Activities and Properties use for testing can be found here
To generate new test artifacts, simply follow these steps.
- Clone the repo.
- run
npm install - run
npm run build.
These commands generate new and/or updated artifacts in the schema/artifacts folder. The generated files need to be committed once generated, so they can be used by each implementing Adobe Target SDK.
Please read the Contributing Guide as well as Code of Conduct for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.