Class: LegoTechSelenium::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/ui/test-cases/TestCase.rb

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Constructor Details

#initialize(name, driver) ⇒ TestCase

Returns a new instance of TestCase.



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ui/test-cases/TestCase.rb', line 6

def initialize(name, driver)
  if name.nil? or name.empty?
    raise "All TestCasses must have a name associated to them"
  end

  if driver.nil?
    raise "The driver is nil in the TestCase"
  end
  @name = name
  @driver = driver

  @actions = []
end

Instance Method Details

#add_action(action) ⇒ Object

Function used to add an action to the list of actions to later be invoked

Parameters:

  • action (Action)

    an object that represents a list of events to invoke

Returns:

  • nil



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ui/test-cases/TestCase.rb', line 23

def add_action(action)
  if action.nil?
    raise "Cannot pass a nil action to TestCase"
  end

  unless action.class.superclass.name.eql? ("LegoTechSelenium::Action")
    raise "action is not an instance of LegoTechSelenium::Action within TestCase"
  end
  @actions.push(action)
  return nil
end

#get_nameString

Function used to get the name of the Test Case instance

Returns:

  • (String)

    Name of the Test Case Instance



37
38
39
# File 'lib/ui/test-cases/TestCase.rb', line 37

def get_name()
  @name
end

#get_number_of_actionsObject

Function get the number of actions within the TestCase

Number

The number of actions within the TestCase



43
44
45
# File 'lib/ui/test-cases/TestCase.rb', line 43

def get_number_of_actions()
  @actions.size
end

#runObject

Function used to invoke all of the actions within the list



48
49
50
51
52
# File 'lib/ui/test-cases/TestCase.rb', line 48

def run()
  @actions.each do |action|
    action.test()
  end
end