Skip to content

Commit

Permalink
Added new tasks for wrapping robot framework's libdoc and testdoc to
Browse files Browse the repository at this point in the history
make it easy to generate html documentation of libraries and test suites
  • Loading branch information
jlantz committed Mar 9, 2018
1 parent f08c3a1 commit fed8955
Show file tree
Hide file tree
Showing 10 changed files with 4,751 additions and 3 deletions.
43 changes: 43 additions & 0 deletions cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,46 @@ tasks:
robot:
options:
suites: cumulusci/robotframework/tests
robot_testdoc:
options:
path: cumulusci/robotframework/tests
output: docs/robot/Test_Suite.html
robot_libdoc_cumulusci:
description:
class_path: cumulusci.tasks.robotframework.RobotLibDoc
options:
path: cumulusci/robotframework/CumulusCI.py
output: docs/robot/CumulusCI_Library.html
robot_libdoc_cumulusci_resource:
description:
class_path: cumulusci.tasks.robotframework.RobotLibDoc
options:
path: cumulusci/robotframework/CumulusCI.robot
output: docs/robot/CumulusCI_Resource.html
robot_libdoc_salesforce:
description:
class_path: cumulusci.tasks.robotframework.RobotLibDoc
options:
path: cumulusci/robotframework/Salesforce.py
output: docs/robot/Salesforce_Library.html
robot_libdoc_salesforce_resource:
description:
class_path: cumulusci.tasks.robotframework.RobotLibDoc
options:
path: cumulusci/robotframework/Salesforce.robot
output: docs/robot/Salesforce_Resource.html

flows:
robot_docs:
description: Generates documentation for robot framework libraries
tasks:
1:
task: robot_libdoc_cumulusci
2:
task: robot_libdoc_cumulusci_resource
3:
task: robot_libdoc_salesforce
4:
task: robot_libdoc_salesforce_resource
5:
task: robot_testdoc
6 changes: 6 additions & 0 deletions cumulusci/cumulusci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ tasks:
robot:
description: Runs a Robot Framework test from a .robot file
class_path: cumulusci.tasks.robotframework.Robot
robot_testdoc:
description:
class_path: cumulusci.tasks.robotframework.RobotTestDoc
options:
path: tests
output: test_suites.html
run_tests:
description: Runs all apex tests
class_path: cumulusci.tasks.apex.testrunner.RunApexTests
Expand Down
15 changes: 12 additions & 3 deletions cumulusci/robotframework/Salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,22 @@ class Salesforce(object):
def __init__(self, debug=False):
self.debug = debug
self.current_page = None
self.builtin = BuiltIn()
self.selenium = self.builtin.get_library_instance('SeleniumLibrary')
self.cumulusci = self.builtin.get_library_instance('cumulusci.robotframework.CumulusCI')
self._session_records = []
# Turn off info logging of all http requests
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARN)

@property
def builtin(self):
return BuiltIn()

@property
def cumulusci(self):
return self.builtin.get_library_instance('cumulusci.robotframework.CumulusCI')

@property
def selenium(self):
return self.builtin.get_library_instance('SeleniumLibrary')

def current_app_should_be(self, app_name):
""" EXPERIMENTAL!!! """
locator = locators['app_launcher']['current_app'].format(app_name)
Expand Down
2 changes: 2 additions & 0 deletions cumulusci/tasks/robotframework/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from cumulusci.tasks.robotframework.robotframework import Robot
from cumulusci.tasks.robotframework.robotframework import RobotLibDoc
from cumulusci.tasks.robotframework.robotframework import RobotTestDoc
39 changes: 39 additions & 0 deletions cumulusci/tasks/robotframework/robotframework.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from cumulusci.core.tasks import BaseTask
from cumulusci.tasks.salesforce import BaseSalesforceTask
from robot.run import run
from robot.libdoc import libdoc
from robot.testdoc import testdoc

class Robot(BaseSalesforceTask):
task_options = {
Expand Down Expand Up @@ -60,3 +63,39 @@ def _run_task(self):
variable=self.options['vars'],
**self.options['options']
)

class RobotLibDoc(BaseTask):
task_options = {
'path': {
'description': "The path to the robot library to be documented. Can be a python file or a .robot file.",
'required': True,
},
'output': {
'description': "The output file where the documentation will be written",
'required': True,
},
}

def _run_task(self):
return libdoc(
self.options['path'],
self.options['output'],
)

class RobotTestDoc(BaseTask):
task_options = {
'path': {
'description': "The path containing .robot test files",
'required': True,
},
'output': {
'description': "The output html file where the documentation will be written",
'required': True,
},
}

def _run_task(self):
return testdoc(
self.options['path'],
self.options['output'],
)
Loading

0 comments on commit fed8955

Please sign in to comment.