简体   繁体   English

使用SLIM编写使用Python的Fitnesse测试

[英]Using SLIM to write Fitnesse tests using Python

I downloaded and ran the fitnesse-standalone to test how does the SLIM protocol work. 我下载并运行了fitnesse-standalone,以测试SLIM协议如何工作。

Below is the directory structure 下面是目录结构

/Users
   |
    -redmont
         |
          -fitnesse-standalone.jar
         |
          -Calc.py
         |
          -FitNesseRoot/

FitNesse Wiki 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 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

I start the fitnesse-standalone using java -jar fitnesse-standalone.jar -p 8080 -v 我使用java -jar开始fitnesse-standalone。-p 8080 -v

The logs in the terminal are 终端中的日志是

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

When I run this fixture in FitNesse with debug, I get the following error: 当我在带有调试功能的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

I am unable to understand why isn't FitNesse able to find my fixture code? 我不明白为什么FitNesse无法找到我的装置代码?

Is it because of some permission? 是因为获得许可吗?

I have also installed waferslim using its egg from cheese shop. 我还使用奶酪店的鸡蛋安装了华夫饼干。

重新安装waferslim可以解决我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM