The easiest way to run MagicPod tests from CircleCI is to use magicpod-api-client and follow these steps to run tests using a cloud device or external cloud service device.
*This is how to download magicpod-api-client.
(To test using simulators or emulators on the CircleCI machine without using the Cloud, for the mobile app test, see Running batch tests using the Local PC and for the browser test, see Run batch tests and command line tests (Local PC test). )
Create run_magicpod_test.sh
First, create run_magicpod_test.sh to run tests using magicpod-api-client.
For mobile app testing, create as follows:
#!/bin/bash -e
# (Using -e, terminate processing at the line where there is a command error)
# Download and unzip the latest version of magicpod-api-client to the current directory
# For security, MAGICPOD_API_TOKEN is set using the CircleCI environment variables
OS=mac # Specify windows for builds on Windows machines and linux for Linux
FILENAME=magicpod-api-client # Any file name
curl -L "https://app.magicpod.com/api/v1.0/magicpod-clients/api/${OS}/latest/" -H "Authorization: Token ${MAGICPOD_API_TOKEN}" --output ${FILENAME}.zip
unzip -fq ${FILENAME}.zip
# Set the various environment variables used by MagicPod.
export MAGICPOD_ORGANIZATION=MagicPod organization name
export MAGICPOD_PROJECT=MagicPod project name
# Upload the app/ipa/apk file to MagicPod, and acquire the FILE_NO.
Path to the FILE_NO=$(./magicpod-api-client upload-app -a app)
# Run batch tests using the app just uploaded and the setting number settings
./magicpod-api-client batch-run -S setting number -s "{\"app_file_number\":\"${FILE_NO}\"}"
# If the test is successful, delete the uploaded app (optional)
if [ $? = 0 ]; then
./magicpod-api-client delete-app -a ${FILE_NO}
fi
- The magicpod-api-client is downloaded for every test, but you can also acquire the latest magicpod-api-client in advance here and add it to the Git repository used by the CircleCI build.
- Define the environment variable MAGICPOD_API_TOKEN, using the CircleCI Project environment settings, etc. The token value can be acquired from this page after logging into MagicPod.
- After creating settings on the test run settings panel, specify the setting number for batch run (figure 1). In addition, as the uploaded app file is used to run the test, set the App Type to Cloud upload (figure 1).
Figure 1. The test run settings panel.
For a browser test, it is not necessary to upload the app, so create it as shown below.
#!/bin/bash -e
# (Using -e, terminate processing at the line where there is a command error)
# Download and unzip the latest version of magicpod-api-client to the current directory
# For security, MAGICPOD_API_TOKEN is set using the CircleCI environment variables
OS=mac # Specify windows for builds on Windows machines and linux for Linux
FILENAME=magicpod-api-client # Any file name
curl -L "https://app.magicpod.com/api/v1.0/magicpod-clients/api/${OS}/latest/" -H "Authorization: Token ${MAGICPOD_API_TOKEN}" --output ${FILENAME}.zip
unzip -fq ${FILENAME}.zip
# Set the various environment variables used by MagicPod.
export MAGICPOD_ORGANIZATION=MagicPod organization name
export MAGICPOD_PROJECT=MagicPod project name
#Use the setting number settings, and run tests as a batch
./magicpod-api-client batch-run -S Setting number
Edit the CircleCI settings file
Next, add the CircleCi job to run run_magicpod_test.sh. The job settings are as shown below.
magic-pod-e2e-test:
steps:
# Run the necessary processing, such as checkout, app builds, etc.
# ... Middle part omitted ....
- run:
name: MagicPod E2E test
command: bash run_magicpod_test.sh