-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from bugsnag/tms/build-apps
Placeholder e2e tests for Android target
- Loading branch information
Showing
13 changed files
with
312 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Mazerunner tests | ||
|
||
E2E tests are implemented with our notifier testing tool [Maze runner](https://github.com/bugsnag/maze-runner), | ||
which is a black-box test framework written in Ruby. | ||
|
||
End to end tests are written in cucumber-style `.feature` files, and need Ruby-backed "steps" in order to know what | ||
to run. The tests are located in the `features` subdirectories beneath [`test`](/test/). | ||
|
||
There are separate sets of tests for the desktop and mobile targets. | ||
|
||
## Mobile tests | ||
|
||
### Building the test fixture | ||
|
||
Building the mobile test fixtures currently assumes a macOS based Unity installation. To build any test fixture, | ||
from the root of the repository, first build the notifier: | ||
``` | ||
rake plugin:export | ||
``` | ||
This will generate the following files: | ||
* `Bugsnag.unitypackage` | ||
* `Bugsnag-with-android-64bit.unitypackage` | ||
|
||
#### Android | ||
|
||
To build the Android test fixture: | ||
``` | ||
UNITY_VERSION=2018.4.34f1 ./test/mobile/features/scripts/build_fixture.sh | ||
``` | ||
Where `UNITY_VERSION` corresponds to the Unity installation path, e.g: | ||
``` | ||
/Applications/Unity/Hub/Editor/2018.4.34f1/Unity.app/Contents/MacOS/Unity | ||
``` | ||
|
||
This will generate a test fixture APK named according to the `UNITY_VERSION`, e.g: | ||
``` | ||
./test/mobile/features/fixtures/maze_runner/mazerunner_2018.4.34f1.apk | ||
``` | ||
|
||
### Running an end-to-end test | ||
|
||
__Note: only Bugsnag employees can run the end-to-end tests for mobile targets.__ We have dedicated test infrastructure | ||
and private BrowserStack credentials that can't be shared outside of the organization. | ||
|
||
Remote tests can be run against real devices provided by BrowserStack. In order to run these tests, you need to set | ||
the following environment variables: | ||
|
||
- A BrowserStack App Automate Username: `BROWSER_STACK_USERNAME` | ||
- A BrowserStack App Automate Access Key: `BROWSER_STACK_ACCESS_KEY` | ||
- A path to a [BrowserStack local testing binary](https://www.browserstack.com/local-testing/app-automate): `MAZE_BS_LOCAL` | ||
|
||
#### Android | ||
|
||
1. `cd test/mobile` | ||
1. Run `bundle install` if you haven't run end-to-end tests before | ||
1. Check the contents of `Gemfile` to select the version of `maze-runner` to use | ||
1. To run the tests: | ||
```shell script | ||
bundle exec maze-runner --app=./features/fixtures/maze_runner/mazerunner_2018.4.34f1.apk \ | ||
--farm=bs \ | ||
--device=ANDROID_9_0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '3.6' | ||
services: | ||
|
||
maze-runner: | ||
image: 855461928731.dkr.ecr.us-west-1.amazonaws.com/maze-runner-releases:latest-v5-cli | ||
environment: | ||
DEBUG: | ||
BUILDKITE: | ||
BUILDKITE_PIPELINE_NAME: | ||
BROWSER_STACK_USERNAME: | ||
BROWSER_STACK_ACCESS_KEY: | ||
volumes: | ||
- ./test:/app/test | ||
- ./test/mobile/features/:/app/features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gem "bugsnag-maze-runner", git: "https://github.com/bugsnag/maze-runner", tag: "v5.0.1" | ||
gem "bugsnag-maze-runner", git: "https://github.com/bugsnag/maze-runner", tag: "v5.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ Assets/Standard\ Assets/Bugsnag/BugsnagBehaviour.cs | |
# Builds | ||
*.apk | ||
*.unitypackage | ||
|
||
maze_runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Linq; | ||
using UnityEngine; | ||
|
||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
|
||
public class Builder : MonoBehaviour | ||
{ | ||
// Generates AndroidBuild/MyApp.apk | ||
public static void AndroidBuild() | ||
{ | ||
Debug.Log("Building Android app..."); | ||
PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "com.bugsnag.mazerunner"); | ||
PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait; | ||
var opts = CommonOptions("mazerunner.apk"); | ||
opts.target = BuildTarget.Android; | ||
|
||
var result = BuildPipeline.BuildPlayer(opts); | ||
|
||
Debug.Log("Result: " + result); | ||
} | ||
|
||
private static BuildPlayerOptions CommonOptions(string outputFile) | ||
{ | ||
var paths = new string[] { "Assets/Scenes/SampleScene.unity", "Assets/Scenes/OtherScene.unity" }; | ||
var newScenes = new EditorBuildSettingsScene[] | ||
{ | ||
new EditorBuildSettingsScene() | ||
{ | ||
path = paths[0], | ||
enabled = true | ||
}, | ||
new EditorBuildSettingsScene() | ||
{ | ||
path = paths[1], | ||
enabled = true | ||
} | ||
}; | ||
|
||
EditorBuildSettings.scenes = newScenes; | ||
|
||
BuildPlayerOptions opts = new BuildPlayerOptions(); | ||
opts.scenes = paths; | ||
opts.locationPathName = Application.dataPath + "/../" + outputFile; | ||
opts.options = BuildOptions.None; | ||
|
||
return opts; | ||
} | ||
} | ||
#endif |
11 changes: 11 additions & 0 deletions
11
test/mobile/features/fixtures/Assets/Editor/Builder.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
test/mobile/features/fixtures/Assets/Plugins/Android/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ -z "$UNITY_VERSION" ] | ||
then | ||
echo "UNITY_VERSION must be set" | ||
exit 1 | ||
else | ||
export PATH="/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS:$PATH" | ||
echo "\`which Unity\`=`which Unity`" | ||
fi | ||
|
||
pushd "${0%/*}" | ||
script_path=`pwd` | ||
popd | ||
|
||
pushd "$script_path/../fixtures" | ||
|
||
# Run unity and immediately exit afterwards, log all output, disable the | ||
# package manager (we just don't need it and it slows things down) | ||
DEFAULT_CLI_ARGS="-quit -batchmode -logFile unity.log -noUpm" | ||
project_path=`pwd`/maze_runner | ||
|
||
# Creating a new project in the MyProject directory | ||
Unity $DEFAULT_CLI_ARGS -createProject $project_path | ||
|
||
# Installing the Bugsnag package | ||
echo "Importing Bugsnag.unitypackage into $project_path" | ||
Unity $DEFAULT_CLI_ARGS -projectPath $project_path -importPackage $script_path/../../../../Bugsnag.unitypackage | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then exit $RESULT; fi | ||
|
||
echo "Importing Bugsnag-with-android-64bit.unitypackage into $project_path" | ||
Unity $DEFAULT_CLI_ARGS -projectPath $project_path -importPackage $script_path/../../../../Bugsnag-with-android-64bit.unitypackage | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then exit $RESULT; fi | ||
|
||
cp -r Assets/Scenes maze_runner/Assets/ | ||
cp -r Assets/Scripts maze_runner/Assets/ | ||
cp Assets/Editor/Builder.cs maze_runner/Assets/Scripts/ | ||
cp Assets/Plugins/Android/AndroidManifest.xml maze_runner/Assets/Plugins/Android | ||
|
||
# Running a custom script - must reference a static method | ||
Unity $DEFAULT_CLI_ARGS -projectPath $project_path -executeMethod Builder.AndroidBuild | ||
RESULT=$? | ||
if [ $RESULT -ne 0 ]; then exit $RESULT; fi | ||
|
||
mv $project_path/mazerunner.apk $project_path/mazerunner_$UNITY_VERSION.apk |