class GARunner

@author Vittorio Monaco

Public Class Methods

new(configuration, filename) click to toggle source

Creates a new instance given a GAConfiguration object and a filename to run tests

@param configuration [GAConfiguration] the configuration you want to use to run the tests (see GAConfiguration) @param filename [String] the name of the file you want to run the tests for @note filename can also be a tests file

# File lib/ga_runner.rb, line 13
def initialize(configuration, filename)
    @configuration=configuration
    @filename=filename
    @runner=XcodebuildRunner.new(configuration)
end

Public Instance Methods

codeFilename() click to toggle source

@return [String] the code file corresponding to @filename, stripping the suffix if @filename is a test file

# File lib/ga_runner.rb, line 50
def codeFilename() 
  suffix = @configuration.suffix
  stripped = @filename
  if isTest()
    stripped = @filename.slice(/(?<file>.*)#{suffix}$/, "file")
  end
  
  return stripped
end
isTest() click to toggle source

@return true if the filename is a tests file

# File lib/ga_runner.rb, line 45
def isTest()
  return @filename.end_with? @configuration.suffix
end
test() click to toggle source

Tries to run unit tests for the filename setup during initialization

(see testIfAvailable)

# File lib/ga_runner.rb, line 39
def test()    
  @runner.prepareForFile(@filename)
  testIfAvailable(codeFilename())
end
testIfAvailable(filename) click to toggle source

Runs unit tests for the given filename, if a tests file exists

@param filename [String] the file you want to run tests for @note filename must be a code file, not a tests file. If you’re not sure whether the file is a tests file or not, use test instead @note if a corresponding tests file cannot be found, outputs a warning line

# File lib/ga_runner.rb, line 24
def testIfAvailable(filename)
    suffix = @configuration.suffix
    
    fileExists = system("find . | grep '" + filename + suffix + "' > /dev/null")
    if !fileExists
      GALogger.log(filename + " doesn't seem to have associated tests. You should think about creating some.", :Warning)
      return
    end
    
    @runner.test(filename)
end