Class: Yolo::Tasks::Ios::OCUnit

Inherits:
BaseTask
  • Object
show all
Defined in:
lib/yolo/tasks/ios/ocunit.rb

Overview

Executes all OCunit related tasks

Author:

  • Alex Fish

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseTask

#name

Constructor Details

#initializeOCUnit

Initializes the class with default settings



18
19
20
21
22
# File 'lib/yolo/tasks/ios/ocunit.rb', line 18

def initialize
  self.sdk = "iphonesimulator" unless sdk
  self.test_output = :junit
  super
end

Instance Attribute Details

#test_outputObject

the test_output type used when running tests, currently only supports :junit



13
14
15
# File 'lib/yolo/tasks/ios/ocunit.rb', line 13

def test_output
  @test_output
end

Instance Method Details

#build_opts_string(*additional_opts) ⇒ String

Overrides the superclass build_opts_string method and appends a pipe if test_ouput is defined

pipe appended if defined

Parameters:

  • additional_opts (Array)

    an array of additional options for the build command

Returns:

  • (String)

    the option string with additional options and test output



32
33
34
35
36
# File 'lib/yolo/tasks/ios/ocunit.rb', line 32

def build_opts_string(*additional_opts)
  options = build_opts + additional_opts
  options = options << "2>&1 | ocunit2junit" if test_output == :junit
  return options.compact.join(" ")
end

#defineObject

Defines rake tasks available to the OCUnit class



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/yolo/tasks/ios/ocunit.rb', line 56

def define
  super
  namespace :yolo do
    namespace :ocunit do
      desc "Runs the specified scheme(s) OCUnit tests."
      task :test do
        xcodebuild :clean
        xcodebuild :build
      end
    end
  end
end

#schemeString

Returns the ocunit class’s scheme attribute, if no attribute is set then check for the scheme env var

Returns:

  • (String)

    The ocunit class’s scheme attribute



43
44
45
46
47
48
49
50
51
# File 'lib/yolo/tasks/ios/ocunit.rb', line 43

def scheme
  scheme = @scheme

  if !scheme
    scheme = ENV['YOLO_OCUNIT_SCHEME']
  end

  return scheme
end