简体   繁体   English

如何使用 FitSharp 在 FitNesse 中设置具有恒定值的符号

[英]How to set symbol with a constant value in FitNesse using FitSharp

I want my FitNesse test setup code to look like something like this, to simulate a drag and drop interaction on a hierarchy menu:我希望我的 FitNesse 测试设置代码看起来像这样,以模拟层次结构菜单上的拖放交互:

$SalesCubeID = 1
$ProductNodeID = 3
$DropTargetID = 4

|script            | hierarchy |
|selectNode;       | SalesCubeID | ProductNodeID |
|dropSelectedNode; | DropTargetID|

It all works when I hard code the values into the table, but I would like to use symbols to improve the readability.当我将值硬编码到表中时,这一切都有效,但我想使用符号来提高可读性。 But I can't work out how to set the Symbol values like this.但是我不知道如何像这样设置 Symbol 值。

I have seen other code using an 'echo' fixture to set the values in a script table like this:我已经看到其他代码使用“回声”装置来设置脚本表中的值,如下所示:

|script       | echo fixture |
|$SalesCubeID=|echo|1|

but I get the exception:但我得到了例外:

Method echo not found in fitSharp.Slim.Operators.InvokeInstructionBase+NullInstance

What do I have to do to use the echoFixture in FitSharp?在 FitSharp 中使用 echoFixture 需要做什么? Or is there another way of setting symbols to constant values?或者是否有另一种将符号设置为常量值的方法?

Well, actually I had the same issue yesterday... At first I used this tip, but then I switched to the manuals :-)好吧,实际上我昨天也遇到了同样的问题......起初我使用了这个技巧,但后来我切换到手册:-)

A set of helper fixtures exist just to do that:一组辅助装置就是为了做到这一点:

!|StringFixture|
|field|field?|
|some value|>>someSymbol|
|some other value|>>otherSymbol|

You can assign multiple symbols.您可以分配多个符号。 And there are such fixtures for String, Int, Long, Float, Double, Decimal and Bool.并且对于 String、Int、Long、Float、Double、Decimal 和 Bool 有这样的装置。

You need to write you own fixture to do this.您需要编写自己的夹具来执行此操作。 Echo is in the Java code and not accessible to a fitSharp test. Echo 位于 Java 代码中,fitSharp 测试无法访问。

It doesn't have to be too fancy.它不必太花哨。

public class Define
{

   public string define(string value)
        {
            return value;
        }
    }
}

Then add this to your .Net assembly path.然后将此添加到您的 .Net 程序集路径。

Finally, in your test page add the following table:最后,在您的测试页面中添加下表:

|Library|
|Define|

Then you should be able to use the define method in your tests.然后你应该能够在你的测试中使用定义方法。 We called it Define, but you could call it echo.我们称之为定义,但你可以称之为回声。 It's the same thing either way.无论哪种方式都是一样的。 The key thing is having a method that returns what you give it.关键是有一个方法可以返回你给它的东西。

To use the echo fixture I believe it needs to be imported via a library table first:要使用 echo 固定装置,我认为它需要首先通过库表导入:

|Library     |
|echo fixture|

Then you should be able to use it like this:那么你应该能够像这样使用它:

//store a string using the echo fixture
|script                        |
|$myString=|echo|my string here|

You can also use the FitNesse wiki variable markup: http://fitnesse.org/FitNesse.UserGuide.FitNesseWiki.MarkupLanguageReference.MarkupVariables您还可以使用 FitNesse wiki 变量标记: http : //fitnesse.org/FitNesse.UserGuide.FitNesseWiki.MarkupLanguageReference.MarkupVariables

!define SalesCubeID {1} !define ProductNodeID {3} !define DropTargetID {4} !define SalesCubeID {1} !define ProductNodeID {3} !define DropTargetID {4}

|script | |脚本| hierarchy |层次结构| |selectNode; |选择节点; | | ${SalesCubeID} | ${SalesCubeID} | ${ProductNodeID} | ${ProductNodeID} | |dropSelectedNode; |dropSelectedNode; | | ${DropTargetID}| ${DropTargetID}|

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

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