Support for space-separated plain text robotframework files in brackets

I finally pushed the bits that allow the robot framework extension for the brackets editor to support the space-separated format. That format seems to be the preferred format for a lot of people, so hopefully a few more people will start using brackets. This feature is available starting with version 1.2.0 of the extension.

Here is a screenshot showing the robot framework acceptance tests. The screenshots are from OSX, but it works just fine on windows too.

space-format-1

My team doesn’t use the space-separated format, so this code hasn’t gone through very must testing. If you use the space separated format and notice some bugs or unexpected behavior, please submit a bug report here: https://github.com/boakley/brackets-robotframework/issues

Advertisements
Support for space-separated plain text robotframework files in brackets

Introducing robotframework-lint support in brackets

I’m happy to announce that the robot framework extension to brackets now includes integration with robotframework-lint.

brackets-rflint-integration-1

The robot extension for brackets now has a very robust set of features:

  • syntax highlighting
  • code folding
  • smart tab key for inserting pipes
  • run tests from within the editor
  • quickly select contents of a single cell
  • autocomplete and inline documentation via robotframework-hub
  • search for keywords
  • lint support via robotframework-lint

Of course, many of the advanced features of brackets are also available when editing robot files, including:

  • multiple cursors
  • split screens
  • search and replace across files
  • customizable themes

Using the linting feature

The use of robotframework-lint is hooked into the standard linting mechanism of brackets, so you can control whether the window of items will appear or not. In all cases, one or more violations will cause a yellow triangle to appear on the status line.

To use the linting feature you simply need to define how to run robotframework-lint. Do this by selecting “Robot Settings…” from the “Robot” menu, which will display a dialog allowing you define how to call rflint.

You can include any rflint arguments that you want. The current file being edited will be added at the end of the command. The easiest way to do this is to put all of your options in a file, and reference that file with the -A/–argumentfile option.

For example, if you have an argument file named /Users/bryan/rflint.args, you can change the settings to be rflint -A /Users/bryan/rflint.args (note: you cannot use ~ to represent your home directory; you need to use an absolute file name)

Once it has been configured, robotframework-lint will be called every time you save a .robot file. If rule violations are detected they will appear at the bottom of the window. Clicking on an item will move the cursor at or near where the violation was detected.

More information on robotframework-lint

For more information about robotframework-lint see robotframework-lint wiki

Acknowledgements

A huge thank-you to my current employer, Echo Global Logistics who generously allows me to work on this project as part of my day job.

Introducing robotframework-lint support in brackets

Lint for Robot Framework

I’d like to introduce a preview release of a new tool I’m developing called robotframework-lint.

Robotframework-lint, or rflint for short, is a lint-like static analysis tool for robot framework plain text files. For a given test suite or resource file it will run a series of rules against the suite, its test cases and keywords.

The purpose is to automatically detect certain anti-patterns in your test assets. For example, it can catch duplicate test case or keyword names, flag deviance from local standards such as disallowing spaces in tag names.

A brief example

Consider the following test suite file:

*** Test Cases ***
| Hello, rflint!
| | [Tags] | example tag
| | log | hello, rflint!

This is what happens when you run rflint against this file:

$ python -m rflint hello.robot
+ hello.robot
W: 1, 0: No suite documentation (RequireSuiteDocumentation)
E: 2, 0: space not allowed in tag name: 'example tag' (TagWithSpaces)
E: 3, 0: No testcase documentation (RequireTestDocumentation)

Rflint caught three problems:

  • A warning that there is missing suite documentation on line 1
  • An error saying that there is a tag with a space on line 2
  • An error that there is missing test case documentation on line 3

If you want to ignore the TagWithSpaces error you can control that from the command line:

$ python -m rflint --ignore TagWithSpaces hello.robot
W: 1, 0: No suite documentation (RequireSuiteDocumentation)
E: 3, 0: No testcase documentation (RequireTestDocumentation)

rflint will exit with a zero exit code if no errors were found. Otherwise the exit code represents the number of errors. You can use this in a CI server or commit hook to prevent a test from being accepted if it has any errors.

Interactive help

You can get a list of all of the command line options by using the --help option:

$ python -m rflint --help
usage: python -m rflint [-h] [--error ] [--ignore ] [--warn ] [--list]
[--no-filenames] [--format FORMAT]
...

A style checker for robot framework plain text files
...

You can get a list of all of the currently installed rules with the --list option:

$ python -m rflint --list
'E DuplicateKeywordNames'
'E DuplicateTestNames'
'E RequireKeywordDocumentation'
'W RequireSuiteDocumentation'
'E RequireTestDocumentation'
'E TagWithSpaces'

A simple rule

Rules are python classes that implement an apply method. Depending on the inherited class, a rule may be given a reference to a suite object, a testcase object, or a keyword object.

Here is an example rule that checks for duplicate test case names within a suite:

import rflint.rule as rule

class DuplicateTestNames(rule.SuiteRule):
    '''Verify that no tests have a name of an existing test 
       in the same suite
    '''
    severity = rule.ERROR

    def apply(self, suite):
        cache = []
        for testcase in suite.testcases:
            if name in cache:
                self.report(suite, testcase.linenumber, "Duplicate testcase name")
                cache.append(name)

Adding custom rules

Built-in rules can be found in the rules folder inside the rflint module. Rules are also looked for in a folder named site-rules, which is where your custom rules should go.

Where can I find robotframework-lint?

rflint is available on github: https://github.com/boakley/robotframework-lint

You can also install with pip, which will install the module “rflint” in the standard place:

$ pip install robotframework-lint

Online documentation

Being a preview release, documentation isn’t complete. However, what
documentation there is can be found on the github wiki for the
project, here:

https://github.com/boakley/robotframework-lint/wiki

Want to contribute?

Would you like to contribute? I would love to have help growing rflint
into an indispensable part of the robot framework tool chain. There is
an opportunity to work on the base code, or to contribute
rules. Simply fork the repository and submit pull requests. You can
also ask questions on the robotframework-users mailing list.

Acknowledgements

A huge thank-you to my current employer, Echo Global Logistics
(http://www.echo.com) who generously allows me to work on this
project as part of my day job.

Lint for Robot Framework

Robot framework extension for brackets version 1.0.0

After a bit too long of a delay, version 1.0 of the robot framework extension for brackets is available. Download and install it in the usual way, through the extension manager.

This version brings two significant new features: keyword search, and the ability to run tests right from within brackets. Both of these features are available via hotkey, but can also be started from the new Robot menu on the menubar.

Keyword search

If you are running the robot framework hub, you can search through all of the keywords right from within brackets. From the Robot menu select “Show keyword search window” and it will display a list of keywords along with their synopsis. You can filter the list, and there is a link that allows you to paste the highlighted keyword into the editor.

brackets-keyword-search

Test runner

Version 1.0.0 now includes the ability to run robot right from within the editor. When you run a test, a window will slide up from the bottom with the output of the pybot/jybot command.

The command to be run is configurable. If you include the string %SUITE in the command, it will be replaced with the name of the suite that is currently being edited. For example, if you are editing “smoke.robot”, “%SUITE” will be replaced with “smoke”. This would typically be used with the –suite option.

brackets-runner

Robot Menu

This version adds a “Robot” menu to the menubar, which provides a way to learn the shortcuts associated with the test runner and keyword search.

Bug fixes

In addition to the new features, a few small bugs have been ironed out as well, such as better support for dark themes.

Robot framework extension for brackets version 1.0.0

Brackets robot framework extension 0.9.5 is out

I’ve pushed a new version of the robot framework plugin for brackets. This version has improved coding hinting support. Code hints now behave a bit more like other editors.

There is also now some basic support for hinting variables. If you type "${" (without the quotes), a list of all variables in the current file will be presented. I’ll be improving this in future releases to include variables defined in resource files.

Another feature is a special shortcut vv — type vv at the start of a cell to automatically insert “${}“, move the cursor inside the curly braces, and bring up the list of variables. It’s a seemingly simple thing, but seems to add to the editing experience by cutting down the number of times you have to type cumbersome characters.

Finally, keyword hints (when you press control-space in a place where a keyword is likely) now includes local keywords. Prior to this change it only picked up keywords in external libraries and resource files.

For more information, see the Changelog

Brackets robot framework extension 0.9.5 is out

Introducing Robot Framework extension for Brackets

Looking for a good text editor for creating robot framework plain text files? I’ve been working on an extension for the fantastic brackets editor. To install, simply install the brackets editor, go to the extension manager, and search for “robot”.

Project page: https://github.com/boakley/brackets-robotframework
Project wiki: https://github.com/boakley/brackets-robotframework/wiki

Features of the extension

The robot extension for brackets provides the following features:

  • syntax highlighting
  • code folding
  • smart handling of the tab key
  • code completion (if you have robotframework-hub installed)
  • in-editor keyword documentation (again, if you have robotframework-hub installed)

What is “smart handling of the tab key”?

I recommend using the pipe-delimited plain text format for test cases. I think this is the best combination of easy-to-read and easy-to-write. Unlike the tab- and space-separated formats, the separation of cells is more evident, which I think is important.

One downside of this format is that it’s tedious typing “| |” on most lines. Even worse is a continuation line which begins with “| | ... |“.

With this extension, pressing tab on a blank line automatically inserts pipes, spaces and continuation characters intelligently, removing some of the tedium with this format.

Want to start a new test case? A single tab on a blank line gives you the opening “|” (pipe-space) sequence.

Want to add a new statement to the current test case? Two tabs will get you the leading “| |” (pipe-space-pipe-space).

Want to add a new cell at the end of the current statement? If the cursor is at the last character and you press tab, it will insert “|” to start a new cell. Pressing tab immediately again will remove the trailing “|“, start a new line, and then insert the same number of pipes and spaces as the line you were just editing.

The general idea is to try and get the tab key to “do the right thing”. I’m still refining exactly what that means, but what it has now seems to work pretty well.

Why another extension for another editor?

There are already extensions for several popular text editors. Why create another one?

If I’m honest, it’s partly due to my own hubris. I have some slightly radical ideas for where I want this extension to go, and these ideas might not mesh with existing projects. So, why not write my own?

Another factor is that brackets is based on the remarkable codemirror widget, and I had recently spent a lot of time working with codemirror at my previous job. I’m wanting to strengthen my own javascript skills (which are extremely weak), so this is a chance for me to grow, professionally.

Considering all that, it was easier for me to create a new extension rather than to fork an existing extension and become a contributor.

Integration with robotframework-hub

Another project I’ve been working on is [robotframework-hub (https://github.com/boakley/robotframework-hub/wiki). The hub is a web app and api for serving up information about keywords.

If you are running the hub on your machine, the brackets extension can use the hub API to provide autocomplete and in-editor keyword documentation. Soon you’ll also be able to search your keywords right within the editor.

Summary

My goal with this extension is to give automation engineers a high quality editing tool, so they can focus more on the test case and less on the mechanics of editing the test.

Acknowledgements

A huge thank-you to my current employer, Echo Global Logistics who generously allows me to work on this project as part of my day job.

Introducing Robot Framework extension for Brackets

I’ve been working on a new project lately, called Robot Framework
Hub. It’s a lame name, I know. Suggest a better name and maybe I’ll
use it!

The project is now to the point where it’s ready to be used by more
people than just me and my team. In invite you to take a look. If
you’re impatient and want to see some screenshots before going to the
trouble of installing it, visit the rfhub wiki here:
https://github.com/boakley/robotframework-hub/wiki

What is robot framework hub?

What is the hub (I’ll use “rfhub” from here on out)? In short, rfhub
is a light weight, zero configuration web application and api for
serving up documentation for all of the robot framework keywords on
your system.

Tired of hitting the internet for library documentation? rfhub solves
that problem. Also, you can get documentation for all of the keywords
in your local resource files and private libraries in addition to
documentation for built-in keywords and installed libraries. Rfhub
also allows you search across all your keywords at once.

Want to try it out? it’s crazy easy to get started. All you need is
python and the robot framework, and a working internet
connection. Open up a terminal or command prompt and issue these two commands:

$ pip install robotframework-hub
$ python -m rfhub

That’s it! Now you can browse to <http://localhost:7070/doc&gt; to see the
documentation for the keywords on your system. Want to use the api?
<http://localhost:7070/api/keywords&gt; will return all of the keywords as
a JSON object. You can also search by name, or get a list of keywords
for a particularly library.

If you want to tell it where to find your own keywords, just add one
or more directories as arguments. For example, if you have keywords in
/src/tests/keywords, you can run the hub like this to see the
documentation for all of the resource files in that directory:

$ python -m rfhub /src/tests/keywords

Although serving documentation is all it does now,
I have pretty big plans for the hub — I want it to have a
dashboard to control your testing activities, a way to view robot
framework documentation, and a UI for running tests and viewing test
results amoung other ideas.

What rfhub is not

There’s another robot framework documentation system out there called
rfdocs (http://www.rfdocs.org). rfhub is not a replacement for
rfdocs. It is, however, an alternative. Whereas rfdocs is an
enterprise-class tool for managing the documentation for multiple
versions of libraries, rfdoc is a tool specifically for viewing the
documentation actually installed on your workstation.

Where can I find it?

rfhub is available on github: https://github.com/boakley/robotframework-hub

There’s a bit of information on that landing page, along with links to
the source. Be sure to check out the wiki which you can get to from
that landing page.

Want to contribute?

Would you like to contribute? I would love to have help growing rfhub
into an indispensable part of your testing toolkit. rfhub is written
in python and uses the flask web application framework. For the front
end I use bootstrap.

Send me an email and we can work out the details.

Acknowledgements

A huge thank-you to my current employer, Echo Global Logistics
(http://www.echo.com) who generously allow me to work on this
project as part of my day job.