使用 SLIM 使用 Python 编写 Fitnesse 测试
Using SLIM to write Fitnesse tests using Python
我下载并运行 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。
重新安装 waferslim 以某种方式解决了我的问题。
我下载并运行 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。
重新安装 waferslim 以某种方式解决了我的问题。