-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustom_runner.py
executable file
·177 lines (159 loc) · 6.79 KB
/
custom_runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/python
import subprocess
import sys
class CustomRunner:
#contants
environment = "LOCAL"
browser = "Chrome"
exitOnfailure = "yes"
runner = "robot"
wallet = "json"
LIST_OF_TAGS = [
"DaoKYCETest", "ForumAdminETest", "DaoOneMilestoneETest", "DaoTwoMilestonesETest", "DaoMetamaskWalletETest",
"DaoSpecialProposalTest", "DaoCreateEditPreviewAbortTest", "DaoAddDocsClaimFailedTest", "DaoCreateWalletRedeemBageTest",
"DaoNoLimitFundingTest", "DaoCreateProposalMetamaskTest", "DaoLikeModuleTest", "DaoCommentModuleTest", "DaoChangeFundingTest",
"DaoSetUsernameEmailTest", "DaoClaimRewardTest", "DAOUnlockDGDTest",
# extras
"DaoProfileOverviewTest", "DaoSideNavMenuTest", "DaoRedeemBadgeTest",
"DaoKYCAdminTest", "DaoKYCSubmissionTest", "DaoCreateNewWalletTest",
"regression", "smoke", "sanity","endtoend",
]
def enter_base_url(self):
print "############################################################"
print "# STEP 1: Setup Environment #"
print "############################################################"
print "1. Local"
print "2. Kovan"
while True:
choice = raw_input("Enter Environment (default %s): " % self.environment)
if choice == '':
break
if choice == '1':
self.environment = 'LOCAL'
break
if choice == '2':
self.environment = 'KOVAN'
break
print "Tests will be run against domain: %s" % self.environment
def choose_browser(self):
print "############################################################"
print "# STEP 2: Select Browser #"
print "############################################################"
print "1. chrome (make sure chromedriver is configured)"
print "2. Headless Chrome"
while True:
choice = raw_input("Enter number (default %s): " % self.browser)
if choice == '':
break
if choice == '1':
self.browser = 'Chrome'
break
if choice == '2':
self.browser = 'headlesschrome'
break
print "Tests will be run in browser: %s" % self.browser
def choose_test_suite(self):
print "############################################################"
print "# STEP 3: Choose Test Suite / Tag #"
print "############################################################"
while True:
self.print_array_of_choices(self.LIST_OF_TAGS)
choice = raw_input("Enter number: ")
try:
choice_int = int(choice)
except (RuntimeError, TypeError, NameError, ValueError):
continue
if choice_int > 0 and choice_int <= (len(self.LIST_OF_TAGS)):
self.test_suite = self.LIST_OF_TAGS[choice_int-1]
break
print "Test Suite / Tag selected: %s" % self.test_suite
def wallet_type(self):
print "############################################################"
print "# STEP 4: Select Wallet Type #"
print "############################################################"
print "1. json"
print "2. metamask"
while True:
choice = raw_input("Enter number (default %s): " % self.wallet)
if choice == '':
break
if choice == '1':
self.wallet = 'json'
break
if choice == '2':
self.wallet = 'metamask'
break
print "Tests will be run in browser: %s" % self.wallet
def exit_on_failure(self):
print "############################################################"
print "# STEP 5: Exit When Any Test Failed? #"
print "############################################################"
print "1. Yes"
print "2. No"
while True:
choice = raw_input("Exit On Any Test Failed (default %s): " % self.exitOnfailure)
if choice == '':
self.exitOnfailure = '--exitonfailure'
break
if choice == '1':
self.exitOnfailure = '--exitonfailure'
break
if choice == '2':
self.exitOnfailure = ''
break
print "Tests will be exit immediately: %s" % self.exitOnfailure
def interpreter_runnner(self):
print "############################################################"
print "# STEP 6: Runner? #"
print "############################################################"
print "1. robot"
print "2. pybot"
print "3. pabot (run 2 test suite in parallel)"
while True:
choice = raw_input("what runner you want to use? (default %s): " % self.runner)
if choice == '':
break
if choice == '1':
self.runner = 'robot'
break
if choice == '2':
self.runner = 'pybot'
break
if choice == '3':
self.runner = 'pabot --processes 4'
break
print "Tests will be runned on: %s" % self.runner
def print_array_of_choices(self, choices):
for choice in choices:
print "%d. %s" % (choices.index(choice)+1, choice)
def generate_command_string(self):
cmd = '%s ' % self.runner
cmd += '--variable ENVIRONMENT:%s ' % self.environment
cmd += '--variable BROWSER:%s ' % self.browser
cmd += '--include %s ' % self.test_suite
cmd += '--variable WALLET:%s ' % self.wallet
cmd += '%s ' % self.exitOnfailure
cmd += '--outputdir Results/%s ' % self.test_suite
cmd += '.'
return cmd
def run_rf(self):
cmd = self.generate_command_string()
print "Script is now running..."
print "############################################################"
print cmd
print "############################################################"
process = subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
for c in iter(lambda: process.stdout.read(1), ''):
sys.stdout.write(c)
for c in iter(lambda: process.stderr.read(1), ''):
sys.stdout.write(c)
if __name__ == "__main__":
app = CustomRunner()
app.enter_base_url()
app.choose_browser()
app.choose_test_suite()
app.wallet_type()
app.exit_on_failure()
app.interpreter_runnner()
app.run_rf()