项目作者: discogs

项目描述 :
:pencil: Create living documentation from BDD specs
高级语言: Python
项目地址: git://github.com/discogs/python-livingdocs.git
创建时间: 2016-08-15T15:18:08Z
项目社区:https://github.com/discogs/python-livingdocs

开源协议:BSD 2-Clause "Simplified" License

下载


Overview

Build Status Coverage Status codecov PyPI PyPI

Using a Python BDD test runner like behave, create living documentation from your BDD feature files. This library will create documents that contain up-to-date information about your BDD specs and helps generate a static site for your living documentation.

Current supported document types:

  • *.mmark files (to be used by Hugo)

Installation

  1. pip install livingdocs

You should also install the Hugo binaries in order to generate your static site: https://gohugo.io/overview/installing/

Quick Start

Use the CLI command livingdocs to configure your Hugo site:

  1. $ livingdocs
  2. Your site's title: <enter title>
  3. Your site's description: <enter description>
  4. ....

This will create a livingdocs folder in your root directory which will have a Hugo skeleton to create a static site.

Using a test runner like behave, you can generate documents for each feature, scenario and step. In environment.py, you can use the DocsMaker to capture this information:

  1. from livingdocs.maker import DocsMaker
  2. def before_all(context):
  3. context.docs = DocsMaker('feature')
  4. def before_scenario(context, scenario):
  5. context.docs.start_scenario(context, scenario)
  6. def after_scenario(context, scenario):
  7. context.docs.end_scenario(context, scenario)
  8. def before_feature(context, feature):
  9. context.docs.start_feature(context, feature)
  10. def after_feature(context, feature):
  11. context.docs.end_feature(context, feature)
  12. def before_step(context, step):
  13. context.docs.start_step(context, step)
  14. def after_step(context, step):
  15. """
  16. if context.browser is an instance
  17. of Selenium Webdriver, then it will
  18. take a snapshot of this step.
  19. """
  20. context.docs.end_step(context, step)

After you have successfully ran your tests, each test step will create its own documentation (and corresponding screenshot if you are using Selenium WebDriver). These new files will be placed in livingdocs/content/features. Once you have generated these files, we can build our static Hugo site with the following commands:

  1. $ cd livingdocs
  2. $ hugo

You will now have a static living docs site in the livingdocs/public directory.

Development

First create a virtual env, then to run the tests use:

  1. tox -e py27

License

  • BSD License