使用 SLIM 使用 Python 编写 Fitnesse 测试
Posted
技术标签:
【中文标题】使用 SLIM 使用 Python 编写 Fitnesse 测试【英文标题】:Using SLIM to write Fitnesse tests using Python 【发布时间】:2015-08-13 14:30:43 【问题描述】:我下载并运行了 Fitnesse-standalone 以测试 SLIM 协议的工作原理。
下面是目录结构
/Users
|
-redmont
|
-fitnesse-standalone.jar
|
-Calc.py
|
-FitNesseRoot/
FitNesse 维基
!contents -R2 -g -p -f -h
!This is a test page
!define TEST_SYSTEM slim
!define SLIM_VERSION 0.1
!path /Users/redmont/Calc.py
!path /Users/redmont/fitnesse-standalone.jar
!define COMMAND_PATTERN python -m waferslim.server --syspath 8080
|import|
|waferslim.examples.decision_table|
|Calc.MyCalc|
|my calc|
|A |B |multiply? |
|1 |2 |2 |
|1 |0 |0 |
|3 |5 |15 |
Calc.py
from waferslim.converters import convert_arg, convert_result, YesNoConverter
class MyCalc(object):
"""
Base test class
"""
def __init__(self):
"""
Initialise instance variables a and b to multiply
"""
self._A = 0
self._B = 0
self._multiply = 0
@convert_arg(to_type=int)
def setA(self, A):
"""
Decorated method to the variable 'a' as an int.
The decorator uses the implicitly registered int converter to
translate from a standard slim string value to an int.
"""
self._A = A
@convert_arg(to_type=int)
def setB(self, B):
self._B = B
@convert_result(to_type=str)
def multiply(self):
return self._A * self._B
我开始使用 Fitnesse-standalone java -jar Fitnesse-standalone.jar -p 8080 -v
终端里的日志是
Socket class: class java.net.Socket
Remote address = /0:0:0:0:0:0:0:1:57853
Local socket address = /0:0:0:0:0:0:0:1:8080
Closed = false
Connected = true
Bound = true
isInputShutdown = false
isOutputShutdown = false
Creating plain socket on port: 0
Trying to connect to host: localhost on port: 57859 SSL=false timeout setting: 10
Creating plain client: localhost:57859
Socket class: class java.net.Socket
Connected to host: localhost on port: 57859 SSL=false timeout setting: 10
Remote address = /127.0.0.1:57860
Local socket address = /127.0.0.1:57859
Closed = false
Connected = true
Bound = true
isInputShutdown = false
isOutputShutdown = false
Read Slim Header: >Slim -- V0.4<
Got Slim Header: Slim -- V0.4, and Version 0.4
当我在 FitNesse 中通过调试运行此夹具时,我收到以下错误:
Could not invoke constructor for MyCalc[0]
1 The instance decisionTable_1.setA. does not exist
2 The instance decisionTable_1.setB. does not exist
2 The instance decisionTable_1.multiply. does not exist
我无法理解为什么 FitNesse 无法找到我的灯具代码?
是因为某些许可吗?
我还使用奶酪店的鸡蛋安装了waferslim。
【问题讨论】:
【参考方案1】:重新安装waferslim不知何故解决了我的问题。
【讨论】:
以上是关于使用 SLIM 使用 Python 编写 Fitnesse 测试的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Slim 中访问 POST 请求的 JSON 请求正文?
PythonStock(34)使用AKShare 做股票数据出来,替换现有每日数据,job相关任务,制作基础镜像使用python3.7-slim-stretch,akshare使用 0.9.65 版本