def ide_feature_list(args, query): ide = args["ide_name"].lower() if ide in ide_support: return Result(message=""" Following are the features: * """ + "\n* ".join(ide_support[ide].keys())) return Result(message="IDE {} is not supported.".format(args['ide_name']))
def ci(args, q): if args["ci"] in ci_tools: key = args["ci"].capitalize() + " Gauge " + DOCUMENTATION return Result(message=""" Gauge can be easily integrated with {}. Steps to Integrate Gauge with {} tool: * Install the Gauge and language plugin on CI machine * Add gauge commands as tasks in CI to run tests. For example, to run the specs use `gauge specs`. * Gauge returns html-reports, console output as result of execution which can be configured to view on CI. """.format(args["ci"], args["ci"]), links={key: ci_tools[args["ci"]]}) return Result(message=""" Gauge can be easily integrated with any Continuous Integration environment. Unfortunately, the documentation is missing for {} tool. """.format(args["ci"]))
def validation_failed(a, q): return Result(message=""" These generally occur if step implementation is not found for a particular step. * Ensure the step implementation for the step has been added. * The step template marking the step in code is case sensitive and should match the step usage in the spec file. """)
def config(args, query): if args['config'] in configs: res = configs[args['config']] return Result(message=res.message, code=res.code, links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/advanced_readings/configuration/", }) return fallback(query)
def install_location(a, q): return Result(message=""" By default the plugins are stored at `%APPDATA%\gauge\plugins` for windows and `~/.gauge/plugins` in mac and linux. To install plugins at different location, set `GAUGE_HOME` environment variable to the custom location. After setting the GAUGE_HOME env, run the install command. The plugin will get installed at the `GAUGE_HOME` custom location. """)
def ide(a, q): return Result( message="Gauge currently supports following IDE's", links={ "IntelliJ": "http://getgauge.io/documentation/user/current/ide_support/intellij_idea.html", "Visual Studio": "http://getgauge.io/documentation/user/current/ide_support/visual_studio.html", })
def offline_installation(a, q): return Result(message=""" If plugin installation fails due to a network connection issue, you can manually download the plugin distributable. Install it using the -f flag. Example: """, code=""" gauge --install {plugin_name} -f {path_to_zip_file} gauge --install html-report -f html-report-1.0.3-darwin.x86.zip """)
def filter(a, q): return Result( message=""" Run the following command to filter your specs based on tags while execution. """, code="gauge --tags {tag_expression} {path_to_specs_dir}", links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/advanced_readings/execution_types/tagged_execution.html." })
def troubleshoot(a, q): return Result( message="Troubleshooting links", links={ "Logs": "http://getgauge.io/documentation/user/current/troubleshooting/logs.html", "Installation": "http://getgauge.io/documentation/user/current/troubleshooting/installation.html", "Execution": "http://getgauge.io/documentation/user/current/troubleshooting/execution.html", "Intellij IDE plugin": "http://getgauge.io/documentation/user/current/troubleshooting/intellij.html", })
def gauge_api_error(a, q): return Result(message=""" This can occur because of following reasons : * Gauge is not installed * Gauge is installed at custom location and custom_install_location/bin is not in PATH. To Solve this : * If gauge is not installed, install gauge * If gauge is installed at custom location, add custom_install_location/bin to PATH * On custom installation location Set GAUGE_ROOT to custom_install_location * Restart Intellij """)
def language(a, q): return Result( message=""" Currently, Gauge supports following languages """, links={ 'Java': 'http://getgauge.io/documentation/user/current/language_features/', 'Ruby': 'http://getgauge.io/documentation/user/current/language_features/', 'C#': 'http://getgauge.io/documentation/user/current/language_features/', 'Python': 'http://gauge-python.readthedocs.io/en/latest/', 'JavaScript': 'https://getgauge-contrib.github.io/gauge-js/', 'Go': 'https://github.com/getgauge-contrib/gauge-go', })
def reporting(a, q): return Result( message=""" Gauge can generate following types of reports: * spectacle: Static Conversion of specs into html. * html-report: Generates html reports for current execution. * xml-report: Generates junit syle xml reports for current execution. To add above plugins to the project, just run the following command:. """, code="gauge --add-plugin {plugin_name}", links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/reporting_features/" })
def project(a, q): return Result( message=structure.format(skeleton_files['env'], skeleton_files['specs'], skeleton_files['manifest']), links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/getting_started/project_structure/", }, code=""" |--- env --- default --- default.properties | |--- manifest.json | |--- specs --- example.spec """)
# -*- coding: utf-8 -*- from gauge.constants import DOCUMENTATION from response.fallback import fallback from response.result import Result gauge = Result(message=""" Gauge is an open source, light-weight cross-platform test automation tool with the ability to author test cases in the business language. It has multi language and multi IDE support. Please visit http://getguage.io for more info. """) specification = Result(message=""" A specification describes a particular feature of the application under test and contains test cases which can also act as your feature documentation. """) scenario = Result(message=""" A scenario represents a single flow/test case in a particular specification. A specification must contain at least one scenario. """) context = Result(message=""" Contexts or Context steps are steps defined in a spec before any scenario. They allow you to specify a set of conditions that are necessary for executing scenarios in a spec. Context steps can be used to set up data before running scenarios. """) tag = Result(message=""" Tags are used to associate labels with specifications or scenarios. Tags are written as comma separated values in the spec with a prefix `tag:`. For example: """, code="Tags: tag1, tag2")
step = "Every step needs to have a language specific implementation that gets executed on the spec execution." alias = """Multiple Step names for the same implementation. The number and type of parameters for all the steps names must match the number of parameters on the implementation.""" custom_screenshot = """This is used when there is need to take CustomScreenshots and not the default one taken by Gauge because you need only a part of the screen captured.""" data_stores = """Data(Objects) can be shared in steps defined in different classes at runtime using DataStores exposed by Gauge. Suite, Spec, Scenario are the different type of data stores available in Gauge.""" hooks = """Test execution hooks can be used to run arbitrary test code as different levels during the test suite execution. Before/After hooks are available at suite, spec, scenario, step in Gauge.""" continue_on_failure = "This feature provides a way to have a particular step implementation not break execution due to failure." java = { "step implementation": Result(message=step, code=""" @Step("Say <greeting> to <product name>") public void helloWorld(String greeting, String name) { } """), "refactoring": Result(message=refactoring.format("Java")), "alias": Result(message=alias, code=""" @Step({"Say <greeting> to <product name>", "Wish <greeting> to <product name>"}) public void helloWorld(String greeting, String name) { } """), "custom screenshot": Result(message=custom_screenshot, code=""" public class CustomScreenGrabber implements ICustomScreenshotGrabber {
def fallback(query): fb.query(query) return Result(message=random.choice(fallback_responses))
from gauge.constants import DOCUMENTATION from response.fallback import fallback from response.result import Result configs = { "gauge_repository_url": Result(message=""" This property is set to an url, which acts as plugin repository for Gauge. Please do not change this url or it will break the installation and update of Gauge plugins. """, code="gauge_repository_url = http://raw.github.com/getgauge/gauge-repository/master"), "gauge_templates_url": Result(message=""" This property is set to an url, which acts as template repository for Gauge. Please do not change this url or it will break the project initialization using templates. """, code="gauge_templates_url = https://dl.bintray.com/gauge/Templates"), "runner_connection_timeout": Result(message=""" This property sets the timeout in milliseconds for making a connection to the language runner. """, code="runner_connection_timeout = 30000"), "plugin_connection_timeout": Result(message=""" This property sets the timeout in milliseconds for making a connection to plugins (except language runner plugins). """, code="plugin_connection_timeout = 10000"), "plugin_kill_timeout": Result(message=""" This property sets the timeout in milliseconds for a plugin to stop after a kill message has been sent. """, code="plugin_kill_timeout = 10000"), "runner_request_timeout": Result(message=""" This property sets the timeout in milliseconds for requests from the language runner. If the size of the project is too big, Gauge may timeout before the runner returns the response message. This value can be configured accordingly. """, code="runner_request_timeout = 10000"), "gauge_exclude_dirs": Result(message="""
def initialization(args, q): return Result( message="Run `gauge --init {}` to initialize a {} project.".format( args['template'], args['template']))
from gauge.constants import DOCUMENTATION from response.result import Result intellij = { "install": Result( message=""" Plugin can be installed by downloading from Jetbrains plugin repository. Steps to install Gauge Intellij IDEA plugin from IDE: * Open the Settings dialog (e.g. ⌘ Comma), select Plugins. * On the right-hand part of the dialog, click the Browse repositories button. * In the dialog that opens, search for Gauge. * Right-click on Gauge and select Download and Install. """, links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/ide_support/intellij_idea.html#installation", }), "init": Result(message=""" * File -> New Project. * Choose 'Gauge' * Choose the project location and java sdk * Finish Note: If gauge-java is not installed, it will download it for the first time. """), "autocomplete":
def validate(a, q): return Result( message= "Run the following command to print all the parse and validation errors.", code="gauge --validate {path_to_specs_dir}")
def open_files(a, q): return Result(message=""" This error occurs when the upper limit to open the number of files is too low. To fix the error, increase the upper limit by adding the following command to your ~/.profile file and login again. """, code="ulimit -S -n 2048")
from response.fallback import fallback from response.result import Result install = { 'windows': Result( message=""" Two ways to install Gauge on windows * Run `choco install gauge`. """, links={ "Download installer": "http://getgauge.io/documentation/user/current/installations/operating_system/install_on_windows.html" }), 'linux': Result( links={ "linux installation docs": "http://getgauge.io/documentation/user/current/installations/operating_system/install_on_linux.html" }), 'mac': Result( message=""" Two ways to install Gauge on mac * Run `brew install gauge`. """, links={ "Download installer": "http://getgauge.io/documentation/user/current/installations/operating_system/install_on_mac.html" }), }
def start_failed(a, q): return Result(message=""" The language plugin installed is not compatible with the gauge version installed. Run the following command to install the latest compatible version. """, code="gauge --install {language_plugin}")
from response.fallback import fallback from response.result import Result syntax = { "spec": Result(code=""" Specification name or # Specification name ================== """), "scenario": Result(code=""" Scenario name or ## Scenario name ------------- """), "step": Result(code="* Step Name"), "tags": Result(code="Tags: login, admin"), "concept": Result(code=""" concept name or # concept name ============ """), "static parameter": Result(code="\"param\""), "dynamic parameter": Result(code="<param>"), "table parameter": Result(code=""" | id | name | |------|---------| | 123 | John | | 456 | Mcclain | """), "special parameter": Result(code="<prefix:value>"), } def cheat_sheet(args, query):
def skeleton(args, query): return Result( message=skeleton_files[args['skeleton']] if args['skeleton'] in skeleton_files else fallback(query))
def run_tool(args, q): if args['runTool'] in tools and args['operation'] in tools[args['runTool']]: return tools[args['runTool']][args['operation']] return Result(message="Operation {} is not supported in {}".format(args['operation'], args['runTool']))
from gauge.constants import DOCUMENTATION from response.fallback import fallback from response.result import Result types = { "parallel": Result(message="Run the following command to execute specs in parallel.", code="gauge -p -n {number of streams} {path to specs dir}"), "serial": Result(message="Run the following command to execute specs in serial.", code="gauge {path_to_specs_dir}"), "tagged": Result(message=""" Tags allow you to filter the specs and scenarios quickly for execution. To execute all the specs and scenarios which are labelled with certain tags, use the following command. """, code='gauge --tags "tag1,tag2" specs'), "table driven": Result( message=""" When scenarios in a specification are to be executed for multiple sets of data then Data table execution can be used. The header names from the table can be used in the steps by specifying in angular brackets `<>`(dynamic parameters). On execution each scenario will be executed for every data row from the table. """, links={ DOCUMENTATION: "http://getgauge.io/documentation/user/current/advanced_readings/execution_types/table_driven_execution.html" }) }
def ide_feature(args, query): ide = args["ide"].lower() if ide in ide_support and args['ideFeature'] in ide_support[ide]: return ide_support[ide][args['ideFeature']] return Result(message="Feature {} is not supported in IDE {}.".format( args['ideFeature'], args['ide']))
from response.result import Result tools = {'maven': { 'execution': Result( message='Run the following command to execute specs using Maven', code="mvn test"), 'validation': Result( message='Run the following command to get all parse and validation errors using Maven', code='mvn -Dflags="--validate"'), 'parallel execution': Result( message='Run the following command to execute specs in parallel using Maven', code="mvn gauge:execute -DspecsDir=specs -DinParallel=true -Dnodes=3"), 'environment': Result( message='Run the following command to execute against a specific environment using Maven', code='mvn gauge:execute -DspecsDir=specs -Denv="dev"'), 'profile': Result( message='Run the following command to execute specs that correspond to a particular test profile in pom.xml', code='mvn gauge:execute -P {profile-name}'), 'tags': Result( message='Run the following command to execute specs by tags using Maven', code='mvn gauge:execute -DspecsDir=specs -Dtags="!in-progress"'), 'flags': Result( message='Run the following command to add additional gauge flags to execution using Maven', code='mvn gauge:execute -DspecsDir=specs -Dflags="--verbose"'), 'spec path': Result( message='Run the following command to specify specs directory using Maven', code='mvn gauge:execute -DspecsDir=specs'), }, 'gradle': { 'execution': Result( message='Run the following command to execute specs using Gradle', code="gradle gauge"), 'validation': Result(
from gauge.constants import DOCUMENTATION from response.fallback import fallback from response.result import Result reporting_plugins = { "xml": Result(message=""" XML Report plugin creates JUnit XML test result document that can be read by tools such as Go, Jenkins. When the specs are executed, the xml report is generated in reports directory in the project. The format of XML report is based on JUnit XML Schema(https://windyroad.com.au/dl/Open%20Source/JUnit.xsd). To add xml-report plugins to the project, just run the following command: """, code="gauge --add-plugin xml-report"), "spectacle": Result(message=""" This is a Gauge plugin that generates static HTML from Specification/Markdown files. Ability to filter specifications and scenarios are available. """, code="gauge --docs spectacle {specs_dir}"), "html": Result(message=""" Reports are generated using html-report plugin. By default html-report is added to the project. When the specs are executed, the html report is generated in reports directory in the project by default. """), } def reporting(a, q): return Result( message="""