简体   繁体   English

Fitsharp,如何给出符号作为参数?

[英]Fitsharp, how to give symbols as argument?

I'm using FitNesse with FitSharp (.Net), and I'm trying to Setup a test suite : 我正在使用FitNesse和FitSharp(.Net),并且正在尝试设置测试套件:

  1. Generate a random port 生成一个随机端口
  2. Setup execution path 设置执行路径
  3. Start process on port , in path , and retreive it's pid port上 ,在path中启动进程,然后获取它的pid

My C# code looks like this: 我的C#代码如下所示:

public int RandomPort() {...}
public int SetupWebsite() {...}
public int StartWebsite(string path, int port) {...}

My Fitnesse looks like this: 我的Fitnesse看起来像这样:

!|Setup|
|RandomPort?|
|>>port|

!|Setup|
|SetupWebsite?|
|>>path|

!|Setup|
|StartWebsite?|<<path|<<port|
|>>pid|

The error : fitSharp.Machine.Exception.MemberMissingException: Member 'startwebsite' with 0 parameter(s) not found for type 'Web.Api.Tests.Setup'. 错误: fitSharp.Machine.Exception.MemberMissingException: Member 'startwebsite' with 0 parameter(s) not found for type 'Web.Api.Tests.Setup'.

I've try many things, but it never works, the problem is not that i'm doing something wrong (wich is obvious), but I can't find how to do it right... 我已经尝试了很多事情,但是它永远都行不通,问题不在于我做错了什么(很明显),但是我找不到正确的做法...

I'm really having a hard time with Fitnesse... I can't find anywhere and up-to-date tutorial, or any ressources to help me creating a nice SuiteTest... To add more context on my question, I want to start an IISExpress (my Setup) on a Web.Api 2 project, And then make some Json/Rest calls on it, my Teardown should simply kill the IISExpress process, and clear the tempory website folder. 我对Fitnesse真的很难过...我找不到任何地方和最新的教程,也找不到任何资源来帮助我创建一个不错的SuiteTest ...要在我的问题上添加更多背景信息,我想在Web.Api 2项目上启动IISExpress(我的安装程序),然后对其进行一些Json / Rest调用,我的Teardown应该简单地杀死IISExpress进程,并清除临时网站文件夹。

Thanks for help ! 感谢帮助 !

The symbol save operator (>>) and the symbol recall operator (<<) can be used to collect a value at one place in a story test and then use it in other places. 符号保存运算符(>>)和符号重新调用运算符(<<)可用于在故事测试中的一个地方收集值,然后在其他地方使用它。 The symbol save operator can be used in any expected value cell. 符号保存运算符可以在任何期望值单元格中使用。 Instead of comparing the actual value to an expected value, the actual value is saved with the symbol name. 代替将实际值与期望值进行比较,将实际值与符号名称一起保存。

You can use the check keyword: 您可以使用check关键字:

!|setup|
|check|randomport|>>port|
|check|setupwebsite|>>path|
|check|startwebsite|<<path||<<port|>>pid|

See http://fitsharp.github.io/Fit/SymbolValues.html 参见http://fitsharp.github.io/Fit/SymbolValues.html

You can also use the name keyword. 您也可以使用name关键字。 The name keyword assigns an object to a symbol name, which can be used to retrieve the object later. name关键字将一个对象分配给一个符号名称,该符号名称可用于以后检索该对象。

!|setup|
|name|port|randomport|
|name|path|setupwebsite|
|name|pid|startwebsite|<<path||<<port|

See http://fitsharp.github.io/Fit/NameKeyword.html 参见http://fitsharp.github.io/Fit/NameKeyword.html

Note that in a method call, the method name is made by concatenating every other cell. 请注意,在方法调用中,方法名称是通过串联其他所有单元格来形成的。 The other alternating cells are input values. 其他交替单元是输入值。

Thanks to Mike, it's almost done. 多亏了迈克,这差不多完成了。 I don't understand why, but i have to change the method StartWebsite , to be something like StartWebsiteOnPortAndPath , so I can split the call... Weird. 我不明白为什么,但是我必须将方法StartWebsite更改为类似StartWebsiteOnPortAndPath ,这样我才能拆分呼叫...很奇怪。

My final result : 我的最终结果:

!|setup|
|check|random port|>>port|
|check|setup website|>>path|
|check|start website on port|<<port|and path|<<path|>>pid|

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

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