使用SLIM编写Python Fitnesse测试

3

我下载并运行了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中使用debug运行这个fixture时,出现以下错误:

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,使用它在奶酪商店中的egg。

1个回答

0
重新安装 waferslim 以某种方式解决了我的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接