Class: Fastlane::Actions::TestmunkAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/testmunk.rb

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, authors, details, output, return_value, sh, step_text

Class Method Details

.authorObject



69
70
71
# File 'lib/fastlane/actions/testmunk.rb', line 69

def self.author
  ["mposchen", "johannesberdin"]
end

.available_optionsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fastlane/actions/testmunk.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :ipa,
                                 env_name: "TESTMUNK_IPA",
                                 description: "Path to IPA",
                                 default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass to existing ipa") unless File.exist? value
                                 end),
    FastlaneCore::ConfigItem.new(key: :email,
                                 env_name: "TESTMUNK_EMAIL",
                                 description: "Your email address",
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass your Testmunk email address using `ENV['TESTMUNK_EMAIL'] = 'value'`") unless value
                                 end),
    FastlaneCore::ConfigItem.new(key: :api,
                                 env_name: "TESTMUNK_API",
                                 description: "Testmunk API Key",
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass your Testmunk API Key using `ENV['TESTMUNK_API'] = 'value'`") unless value
                                 end),
    FastlaneCore::ConfigItem.new(key: :app,
                                 env_name: "TESTMUNK_APP",
                                 description: "Testmunk App Name",
                                 verify_block: proc do |value|
                                   UI.user_error!("Please pass your Testmunk app name using `ENV['TESTMUNK_APP'] = 'value'`") unless value
                                 end)
  ]
end

.descriptionObject



35
36
37
# File 'lib/fastlane/actions/testmunk.rb', line 35

def self.description
  "Run tests on real devices using Testmunk"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/fastlane/actions/testmunk.rb', line 73

def self.is_supported?(platform)
  platform == :ios
end

.run(config) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fastlane/actions/testmunk.rb', line 15

def self.run(config)
  UI.success('Testmunk: Uploading the .ipa and starting your tests')

  UI.success('Zipping features/ to features.zip')
  zipped_features_path = File.expand_path('features.zip')
  Actions.sh(%(zip -r "features" "features/"))

  response = system("curl -H 'Accept: application/vnd.testmunk.v1+json'" \
      " -F 'file=@#{config[:ipa]}' -F 'autoStart=true'" \
      " -F 'testcases=@#{zipped_features_path}'" \
      " -F 'email=#{config[:email]}'" \
      " https://#{config[:api]}@api.testmunk.com/apps/#{config[:app]}/testruns")

  if response
    UI.success('Your tests are being executed right now. Please wait for the mail with results and decide if you want to continue.')
  else
    UI.user_error!("Something went wrong while uploading your app to Testmunk")
  end
end