tc_integration 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/tc_integration.rb +82 -79
- metadata +1 -1
data/lib/tc_integration.rb
CHANGED
@@ -3,107 +3,110 @@ require 'win32ole'
|
|
3
3
|
|
4
4
|
include WIN32OLE::VARIANT
|
5
5
|
|
6
|
+
|
6
7
|
class String
|
7
8
|
def strip_quotes
|
8
9
|
gsub(/\A['"]+|['"]+\Z/, "").gsub("\\\\","\\")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
module TCIntegration
|
14
|
+
|
15
|
+
class TCUnit
|
16
|
+
def initialize(name, tc)
|
17
|
+
@framework, @unit = name.split(".")
|
18
|
+
@integration = tc.integration
|
19
|
+
end
|
20
|
+
private
|
21
|
+
def method_missing(meth, *args, &blk)
|
22
|
+
@integration.RunRoutineEx(@framework, @unit, meth.to_s, WIN32OLE_VARIANT.new(args.map{|a|
|
23
|
+
a.is_a?(String) ? WIN32OLE_VARIANT.new(a, VT_BSTR) : WIN32OLE_VARIANT.new(a, VT_VARIANT|VT_BYREF)}
|
24
|
+
))
|
25
|
+
sleep(1) while @integration.IsRunning
|
26
|
+
@integration.RoutineResult
|
27
|
+
end
|
24
28
|
end
|
25
|
-
end
|
26
29
|
|
27
30
|
|
28
|
-
class TCLibrary
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
class TCLibrary
|
32
|
+
def initialize(name, tc)
|
33
|
+
@framework = name
|
34
|
+
@tc = tc
|
35
|
+
@units = {}
|
36
|
+
end
|
37
|
+
private
|
38
|
+
def method_missing(meth, *args, &blk)
|
39
|
+
raise("?") if(args.count > 0)
|
40
|
+
@units[meth] ||= TCUnit.new(@framework + "." + meth.to_s, @tc)
|
41
|
+
end
|
38
42
|
end
|
39
|
-
end
|
40
43
|
|
41
|
-
class Proj
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
private
|
51
|
-
def method_missing(meth, *args, &blk)
|
52
|
-
raise("?") if(args.count > 0)
|
53
|
-
@libraries[meth] ||= TCLibrary.new(meth.to_s, @tc)
|
54
|
-
end
|
55
|
-
end
|
44
|
+
class Proj
|
45
|
+
def initialize(proj_file)
|
46
|
+
@tc = TC.new
|
47
|
+
@integration = @tc.integration
|
48
|
+
raise("Test Complete is already Running a test") if(@integration.IsRunning)
|
49
|
+
@suite = @integration.OpenProjectSuite(proj_file)
|
50
|
+
@libraries ||={}
|
51
|
+
end
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
|
53
|
+
private
|
54
|
+
def method_missing(meth, *args, &blk)
|
55
|
+
raise("?") if(args.count > 0)
|
56
|
+
@libraries[meth] ||= TCLibrary.new(meth.to_s, @tc)
|
57
|
+
end
|
60
58
|
end
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
tc
|
73
|
-
|
60
|
+
class TC
|
61
|
+
def initialize
|
62
|
+
@tc = TC.get_TC
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.get_TC
|
66
|
+
tc = get_OLE("TestComplete.TestCompleteApplication.9") unless tc
|
67
|
+
tc = get_OLE("TestExecute.TestExecuteApplication.9") unless tc
|
68
|
+
tc = get_OLE("TestComplete.TestCompleteApplication.8") unless tc
|
69
|
+
tc = get_OLE("TestExecute.TestExecuteApplication.8") unless tc
|
70
|
+
tc
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.get_OLE(strAutomationEngine)
|
74
74
|
begin
|
75
|
-
tc = WIN32OLE.
|
75
|
+
tc = WIN32OLE.connect(strAutomationEngine)
|
76
76
|
rescue WIN32OLERuntimeError
|
77
|
+
begin
|
78
|
+
tc = WIN32OLE.new(strAutomationEngine)
|
79
|
+
rescue WIN32OLERuntimeError
|
80
|
+
end
|
77
81
|
end
|
82
|
+
tc
|
78
83
|
end
|
79
|
-
tc
|
80
|
-
end
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
+
def library(name)
|
86
|
+
TCLibrary.new(name, @tc)
|
87
|
+
end
|
85
88
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
+
def method_missing(meth, *args, &blk)
|
90
|
+
@tc.send(meth, *args, &blk)
|
91
|
+
end
|
89
92
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
def StartProcess(executable, parameter, timeout)
|
94
|
+
shell = WIN32OLE.new('WScript.Shell')
|
95
|
+
shell.Run("#{executable} \"#{parameter}\"")
|
93
96
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
processName = executable.split(/[\/\\]/).last.split(/\./).first
|
98
|
+
sys = @tc.GetObjectByName("Sys")
|
99
|
+
x = Now + timeout
|
97
100
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
101
|
+
begin
|
102
|
+
process = sys.Find("ProcessName", processName)
|
103
|
+
end while(!process.Exists && Now < x)
|
104
|
+
return process
|
105
|
+
end
|
106
|
+
|
107
|
+
def LaunchIe(url, timeout)
|
108
|
+
executable = "C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
|
109
|
+
StartProcess(executable, url, timeout)
|
110
|
+
end
|
107
111
|
end
|
108
112
|
end
|
109
|
-
|