我如何使用.Net编写BDD场景,并使用Fitsharp进行格式化

时间:2016-07-27 07:26:12

标签: c# asp.net bdd fitnesse fitsharp

我们需要在Fitnesse中编写场景,然后给予当时(Gherkin) 有没有办法做到这一点?比如java GivWenZen

我们使用Fitsharp在.Net 4.0中使用fitnesse。

情形: 现有的Fitnesse表 -

!define TEST_SYSTEM {fit}
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer %p}
!define TEST_RUNNER {D:\API_TC_Setup\Fitnesse\Runner.exe}


!path D:\API_TC_Setup\FitnesseBDDDemo\FitnesseBDDDemo\bin\Debug\FitnesseBDDDemo.dll

|configure|processor|add operator|findmemberpattern|

!|import |
| FitnesseBDDDemo|
|Class1|
|Given User should login|
|When User place an Order|
|Then Order should present in market|

以下是上述方案的代码

namespace FitnesseBDDDemo
   {
   public class Class1
      {
      [MemberPattern ( "Given User should login" )]
      public void LoginUser1( )
         {
         Console.WriteLine ( "Executing loggin-" );
         }
      //When User place an Order
      [MemberPattern ( "When User place an Order" )]
      public void PlaceOrder( )
         {
         Console.WriteLine ( " Order placing-" );
         }
      //Then Order should present in market
      [MemberPattern ( "Then Order should present in market" )]
      public void OrderInMarket( )
         {
         Console.WriteLine ( "Order in market-" );
         }
      }
   }

错误 -

执行时忽略我的场景时出现错误请查看此快照

FitnesseResult

1 个答案:

答案 0 :(得分:0)

您可以使用FindMemberPattern运算符 请参阅:http://fitsharp.github.io/Fit/FindMemberPatternOperator.html

您的测试可能是:

(这些行可以在祖先页面上进行)

("update Medicine set  Name = ' " + textbox1.Text + " ', Company = ' " + textbox2.Text + " ', Type = ' " + textbox3.Text + " ', Quantity = ' " + textbox4.Text + " ' where P_id =' " + textbox5.Text + " '  "); 

(下一行可以在SetUp页面上进行)

!define TEST_SYSTEM {fit}
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer %p}

您的代码将包含:

|configure|processor|add operator|findmemberpattern|

|Place Order|
|Given User user1 should login|
|When Placing Bid Order|
|Then Order Available In Market|