Skip to content

Latest commit

 

History

History
33 lines (21 loc) · 1.65 KB

TESTINGGA4.md

File metadata and controls

33 lines (21 loc) · 1.65 KB

Testing

This document outlines how to run the automated tests for the Google Analytics Importer plugin- GA4.

System Test

At the moment there is only one test that tests the entire importing process. The test is in ./tests/System/ImportTestGA4.php.

Before running, the following environment variables must be set:

Note: The below details might not work in your local env when you test with CI=0, to fix that ask Matthieu to give your user a view access to http://matthieu.net/blog GA4 account and replace the property id accordingly

$ export GA4_PROPERTY_ID=properties/317278922
$ export GA4_STREAM_IDs=3599588245
$ export CI=1

You must also provide credentials to the test GA site in some way. There are two ways to do this:

Method 1: Specify account credentials via environment variables. The following environment variables must be set: PIWIK_TEST_GA_ACCESS_TOKEN PIWIK_TEST_GA_CLIENT_CONFIG.

Method 2: Configure your local test instance through the UI. The automated test will pick up these credentials and use them.

Note: the test site is the GA4 account for http://matthieu.net/blog.

UI Test

There is a UI test that is used to test the admin UI and the entire workflow for the plugin (except oauth configuration). Unlike the system test it does not use the real Google Analytics API. Instead it uses the responses stored in tests/resources/capturedresponses-ga4.log.

The capturedresponses-ga4.log file is generated by running the system test with the MATOMO_TEST_CAPTURE_GA4_RESPONSES environment variable. It will have to be regenerated if the import process changes and new requests to GA are made or some requests are removed.