forked from slickqa/python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
51 lines (35 loc) · 1.89 KB
/
example.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
#!/usr/bin/env python
from slickqa import SlickQA, ResultStatus, RunStatus
import datetime
import time
slick = SlickQA('http://localhost:8080', 'EP', '10.7', '5', 'My Testplan', environment_name='Example', test_run_group_name='example.py testruns')
results = []
results.append(slick.file_result("First Test", status=ResultStatus.NO_RESULT, runstatus=RunStatus.TO_BE_RUN))
results.append(slick.file_result("Second Test", status=ResultStatus.NO_RESULT, runstatus=RunStatus.TO_BE_RUN))
results.append(slick.file_result("Third Test", status=ResultStatus.NO_RESULT, runstatus=RunStatus.TO_BE_RUN))
results.append(slick.file_result("Fourth Test", status=ResultStatus.NO_RESULT, runstatus=RunStatus.TO_BE_RUN))
results.append(slick.file_result("Fifth Test", status=ResultStatus.NO_RESULT, runstatus=RunStatus.TO_BE_RUN))
# Now to run the tests
for result in results:
result.started = datetime.datetime.now()
result.runstatus = RunStatus.RUNNING
# this updates slick with those properties we just set
result.update()
# pretend the test is running
time.sleep(10)
# add a log entry (will not automatically update the result in slick)
result.add_log_entry("Log Entry, isn't it nice?", level="INFO", loggername="example.test")
result.add_log_entry("Log Entry, isn't it nice?", level="ERROR", loggername="example.test")
# this updates slick with those properties we just set
result.update()
# add a file (will automatically update result in slick)
result.add_file('example.py')
result.finished = datetime.datetime.now()
# give the runlength in total milliseconds
result.runlength = int((result.finished - result.started).total_seconds() * 1000)
result.status = ResultStatus.PASS
result.reason = "Because I said"
result.runstatus = RunStatus.FINISHED
# this updates slick with those properties we just set
result.update()
slick.finish_testrun()