Skip to content

Commit

Permalink
Remove ui-tests from folder
Browse files Browse the repository at this point in the history
helps with #4
  • Loading branch information
janpio committed Aug 6, 2018
1 parent 1c7c61a commit bd34d1d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 19 deletions.
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -24,17 +24,17 @@ By keeping your test files in your `fastlane` folder and offering a simple actio

### `ionic_ios_config_snapshot`

This action get's you started with a sample UI Test configuration (and saves it to `fastlane/cordova_screenshots/ios/ui-tests`). The UI Unit Tests are linked into any existing XCode project generated by Ionic.
This action get's you started with a sample UI Test configuration (and saves it to `fastlane/cordova_screenshots/ios`). The UI Unit Tests are linked into any existing XCode project generated by Ionic.

For example: `fastlane run ionic_ios_config_snapshot ionic_scheme_name:"ionic-screen-shots"`

*You can also specify which Xcode project to use and minimum iOS version using `ionic_ios_xcode_path` and `ionic_min_target_ios` options respectively. The Xcode project will be autodetected as the project (`.xcodeproj`) associated with the workspace (`.xcworkspace`) in `platforms/ios` folder generated by Ionic/Cordova.*

The command above will create a folder `fastlane/cordova_screenshots/ios/ui-tests/ionic-screen-shots`
The command above will create a folder `fastlane/cordova_screenshots/ios/ionic-screen-shots`

`ionic_ios_config_snapshot` also executes the `ionic_config_snapshot` action to retrofit this unit test configuration into any existing Xcode Project.

When this is done. The sample will be linked into your generated project. In the above example, a UI Test scheme will be created in `fastlane/cordova_screenshots/ios/ui-tests/ionic-screen-shots`. The files in this folder are linked absolutely into Xcode, that is Xcode refers directly to these files (they are not copied over to Xcode).
When this is done. The sample will be linked into your generated project. In the above example, a UI Test scheme will be created in `fastlane/cordova_screenshots/ios/ionic-screen-shots`. The files in this folder are linked absolutely into Xcode, that is Xcode refers directly to these files (they are not copied over to Xcode).

#### Writing test code

Expand Down Expand Up @@ -65,7 +65,7 @@ You can now click on the 'Record UI Test' (Red Circle Icon):

This will open the simulator and you can click around in your application. XCode will record, each interaction within the `testSnapshots()` method.

When you are done, you can save everything and it will save those interactions into the `fastlane/cordova_screenshots/ios/ui-tests/ui-snapshots.swift`.
When you are done, you can save everything and it will save those interactions into the `fastlane/cordova_screenshots/ios/ui-snapshots.swift`.

You can now add fastlane `snapshot("decription")` where you like.

Expand All @@ -75,7 +75,7 @@ The UI Test files can be added to your source control and they will be retrofitt

### `ionic_ios_snapshot`

Scans the `fastlane/cordova_screenshots/ios/ui-tests` folder for sub folders that represent UI Test Schemes (each folder is a scheme). It retrofits each UI Test scheme into the XCode projects generated by Ionic. This should be executed before each time you perform [`fastlane snapshot`](https://docs.fastlane.tools/actions/snapshot/) or use the [`capture_ios_screenshots` action](https://docs.fastlane.tools/actions/capture_ios_screenshots/).
Scans the `fastlane/cordova_screenshots/ios` folder for sub folders that represent UI Test Schemes (each folder is a scheme). It retrofits each UI Test scheme into the XCode projects generated by Ionic. This should be executed before each time you perform [`fastlane snapshot`](https://docs.fastlane.tools/actions/snapshot/) or use the [`capture_ios_screenshots` action](https://docs.fastlane.tools/actions/capture_ios_screenshots/).

#### Retrofitting UI Test Scheme via Fastlane

Expand All @@ -85,7 +85,7 @@ The `ionic_ios_snapshot` action can be executed before any other lane in your `F

The parameters for `ionic_ios_snapshot` action will mostly be autodetected. It attempts to pick the Xcode project by looking in `platforms/ios` folder. The `team_id` parameter is automatically set if it is specified in your fastlane `Appfile`. The `bundle_id` is set automatically if the `package_name` parameter is set in your fastlane `Appfile`. All these parameters can be overridden by specifying them in the call to the action. To see what has been automatically picked up for your configuration, use `fastlane action ionic_ios_snapshot`

`ionic_ios_snapshot` lists all the subfolders in the folder `fastlane/cordova_screenshots/ios/ui-tests*`. It then creates a UI Test Target and Scheme based on the name of the subfolder, in the example above, this would be a single target/scheme called `ionic-snap-shots`. It effectively 'retrofits' the UI tests into the iOS Xcode project for you.
`ionic_ios_snapshot` lists all the subfolders in the folder `fastlane/cordova_screenshots/ios`. It then creates a UI Test Target and Scheme based on the name of the subfolder, in the example above, this would be a single target/scheme called `ionic-snap-shots`. It effectively 'retrofits' the UI tests into the iOS Xcode project for you.

After `ionic_ios_snapshot` is executed, you can now specify any of the schemes you generated to be used in fastlane [snapshot](https://github.com/fastlane/fastlane/tree/master/snapshot) action, using the 'scheme' parameter.

Expand All @@ -96,7 +96,7 @@ platform :ios do

before_all do
#
# This will retrofit any existing schemes in fastlane/cordova_screenshots/ios/ui-tests/
# This will retrofit any existing schemes in fastlane/cordova_screenshots/ios/
#
ionic_ios_snapshot(
team_id: "[YOUR TEAM ID]"
Expand Down
2 changes: 1 addition & 1 deletion fastlane/Fastfile
Expand Up @@ -2,7 +2,7 @@ platform :ios do

before_all do
#
# This will retrofit any existing schemes in fastlane/cordova_screenshots/ios/ui-tests/
# This will retrofit any existing schemes in fastlane/cordova_screenshots/ios/
#
ionic_ios_snapshot(
team_id: "[YOUR TEAM ID]",
Expand Down
Expand Up @@ -20,7 +20,7 @@ def self.run(params)
#
# Copy over unit test files
#
UI.message("Creating New UI Unit Tests for Snapshots, with Scheme '#{scheme_name}' in '#{CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}'")
UI.message("Creating New UI Unit Tests for Snapshots, with Scheme '#{scheme_name}' in '#{CordovaScreenshots::IONIC_IOS_CONFIG_PATH}'")
Fastlane::Helper::CordovaScreenshotsHelper.copy_ios_sample_tests(scheme_name)

#
Expand Down Expand Up @@ -53,7 +53,7 @@ def self.return_value

def self.details
# Optional:
"Creates a set of UI Unit Tests in '#{CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}' and configures an existing Cordova/Ionic generated Xcode projec to use them"
"Creates a set of UI Unit Tests in '#{CordovaScreenshots::IONIC_IOS_CONFIG_PATH}' and configures an existing Cordova/Ionic generated Xcode projec to use them"
end

def self.available_options
Expand Down
Expand Up @@ -4,7 +4,7 @@ module Fastlane
module Actions
class IonicIosSnapshotAction < Action
def self.run(params)
UI.message "Configuring Xcode with UI Tests located in '#{CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}/**'"
UI.message "Configuring Xcode with UI Tests located in '#{CordovaScreenshots::IONIC_IOS_CONFIG_PATH}/**'"

(!params.nil? && !params[:ionic_ios_xcode_path].nil?) || UI.user_error!("Mandatory parameter :ionic_ios_xcode_path not specified")

Expand All @@ -21,7 +21,7 @@ def self.run(params)
#
# Find all preconfigured UI Unit Tests
#
schemes = Dir.glob("#{CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}/*/").reject do |d|
schemes = Dir.glob("#{CordovaScreenshots::IONIC_IOS_CONFIG_PATH}/*/").reject do |d|
d =~ /^\.{1,2}$/ # excludes . and ..
end
UI.message "Found schemes: #{schemes}"
Expand Down Expand Up @@ -108,7 +108,7 @@ def self.clean_xcode_project(proj, scheme_name)
product_ref_name = scheme_name + '.xctest'
proj.products_group.files.each do |product_ref|
if product_ref.path == product_ref_name
UI.important "Found existing Code Group '#{product_ref.path}' and removed it."
UI.important "Found existing Product Group '#{product_ref.path}' and removed it."
product_ref.remove_from_project
end
end
Expand All @@ -118,8 +118,8 @@ def self.clean_xcode_project(proj, scheme_name)
proj
end

def self.add_unit_tests_to_xcode_project(proj, scheme_name, config_folder, project_name, target_os)
#
def self.add_unit_tests_to_xcode_project(proj, scheme_name, config_folder, project_name, target_os, team_id, bundle_id, xcode_project_path)
#
# Create new test group
#
UI.message "Creating UI Test Group '#{scheme_name}' for snapshots testing"
Expand Down
1 change: 0 additions & 1 deletion lib/fastlane/plugin/cordova_screenshots/constants.rb
Expand Up @@ -5,7 +5,6 @@ module CordovaScreenshots

IONIC_CONFIG_PATH = "fastlane/cordova_screenshots"
IONIC_IOS_CONFIG_PATH = IONIC_CONFIG_PATH + "/ios"
IONIC_IOS_CONFIG_UITESTS_PATH = IONIC_IOS_CONFIG_PATH + "/ui-tests"

IONIC_DEFAULT_UNIT_TEST_NAME = "ui-snapshots"
end
Expand Down
Expand Up @@ -19,7 +19,7 @@ def self.copy_all_files(src_folder, project_folder)
def self.copy_ios_sample_tests(scheme_name)
ios_resources_path = File.expand_path("#{HELPER_PATH}/../resources/ios")
source_folder = "#{ios_resources_path}/#{CordovaScreenshots::IONIC_DEFAULT_UNIT_TEST_NAME}"
dest_folder = "#{CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}/#{scheme_name}"
dest_folder = "#{CordovaScreenshots::IONIC_IOS_CONFIG_PATH}/#{scheme_name}"
copy_all_files(source_folder, dest_folder)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/cordova_screenshots_helper_spec.rb
Expand Up @@ -35,9 +35,9 @@
it 'should create sample' do
FakeFS.with_fresh do
FakeFS::FileSystem.clone("#{Fastlane::Helper::CordovaScreenshotsHelper::IOS_RESOURCES_PATH}/#{Fastlane::CordovaScreenshots::IONIC_DEFAULT_UNIT_TEST_NAME}")
# FileUtils.mkdir_p "#{Fastlane::CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}/my-sample"
# FileUtils.mkdir_p "#{Fastlane::CordovaScreenshots::IONIC_IOS_CONFIG_PATH}/my-sample"

expected_path = "#{Fastlane::CordovaScreenshots::IONIC_IOS_CONFIG_UITESTS_PATH}/my-sample"
expected_path = "#{Fastlane::CordovaScreenshots::IONIC_IOS_CONFIG_PATH}/my-sample"

Fastlane::Helper::CordovaScreenshotsHelper.copy_ios_sample_tests("my-sample")

Expand Down

0 comments on commit bd34d1d

Please sign in to comment.