转换文档中的测试,以及viceversa
livedoc的Python项目详细描述
Tests | |
Downloads | |
About | |
Status |
关于
受Concordion和Fitnesse和RobotFramework的启发,LiveDoc是一种实时维护文档的方法。
其思想是使用文档作为测试,因此文档也要进行测试。这样你就可以确保它总是更新的,你可以向产品所有者展示漂亮的报告。
原则
- 应该很简单,所以将使用eval来处理嵌入的代码。
- 应该易于使用,通过支持Markdown来避免硬html。
- 应该是可扩展的,允许自定义fixture,就像Concordion那样。
- 应该很强大,通过提供工具来简化工作,就像RobotFramework库那样。
比较
Feature | Concordion | Fitnesse | RobotFramework | LiveDoc |
---|---|---|---|---|
Markdown support | Yes | No | No | Yes |
Customizable output | No | No | No | Yes |
Xunit integration | Yes | Yes | Yes | No |
Xunit results | Yes | Yes | Yes | Yes |
REST test facilities | No | No | Yes | Planed |
Tables to write examples | Yes | Yes | Yes | Yes |
Fixtures language | Java | Many | Python or Java | Python |
HTML generators integration | No | No | No | Yes |
Different kind of tables | No | Yes | No | Planed |
Generates test code | No | No | No | Planed |
它是如何工作的?
LiveDoc解析生成的html,搜索一些特殊代码。你可以任意生成代码。
为了方便地编写Markdown,我选择了Concordion方式:通过在title属性中添加代码到-的链接。示例:
<a href=”-” title=”a = TEXT”>5</a>
这将显示值5和通常的html文本一样,但会将文本分配给变量a。现在您可以使用它进行操作:
<a href=”-” title=”a += TEXT”>5</a>
并检查结果:
<a href=”-” title=”a == TEXT”>10</a>
或者只显示它(LiveDoc将显示分配给OUT变量的任何内容):
<a href=”-” title=”OUT = a”></a>
您还可以在以下两者之间添加文本:
By setting the value of <a href=”-” title=”a = TEXT”>5</a> and adding <a href=”-” title=”a += TEXT”>5</a> more, it will return <a href=”-” title=”a == TEXT”>10</a>.
但这很难写和读,所以可以通过使用Markdown:
By setting the value of [5](- “a = TEXT”) and adding [5](- “a += TEXT”) more, it will return [10](- “a == TEXT)”.
此外,还可以设置测试名称,只需将名称分配给test name变量,将以下任何比较分组为该测试的断言:
If TESTNAME is set to the [test name](- “TESTNAME = TEXT”), then any comparison will be added to that test.
默认情况下,任何标题(h1,h2,…)都设置为测试名称。
请记住,为了更简单,任何比较都是断言。
路线图
- 0.5.0:高级设备
常见问题解答
livedoc是否支持python 2?
不,Python2已被弃用,将于2020年退役,所以请继续使用Python3。