Fork me on GitHub

Mono 3.2 上跑NUnit测试

NUnit是一款堪与JUnit齐名的开源的回归测试框架,供.net开发人员做单元测试之用,可以从www.nunit.org网站上免费获得,最新版本是2.5。Mono 3.2 源码安装的,在/usr/bin/ 下面有2.4.8 版本:

[azureuser@mono /]$ /usr/bin/nunit-console4
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Unix 2.6.32.279
  CLR Version: 4.0.30319.17020 ( 3.3.0 (master/1022c50 Thu Jul 25 13:16:35 UTC 2013) )

fatal error: no inputs specified

本文用一个BDD的框架Bddify 进行测试,关于这个框架的更详细信息可以参看 BDDfy In Action

[azureuser@mono /]$ sudo /usr/bin/nunit-console4 /home/azureuser/BddifySamples/Bddify.Samples.dll
NUnit version 2.4.8
Copyright (C) 2002-2007 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Unix 2.6.32.279
  CLR Version: 4.0.30319.17020 ( 3.3.0 (master/1022c50 Thu Jul 25 13:16:35 UTC 2013) )

.Story: Account holder withdraws cash
        As an Account Holder
        I want to withdraw cash from an ATM
        So that I can get money when the bank is closed

Scenario: Account has insufficient fund
        Given the Account Balance is $10
          And the Card is valid
          And the machine contains enough money
        When the Account Holder requests $20
        Then the ATM should not dispense any Money
          And the ATM should say there are Insufficient Funds
          And the Account Balance should be $20
          And the Card should be returned

.Story: Account holder withdraws cash
        As an Account Holder
        I want to withdraw cash from an ATM
        So that I can get money when the bank is closed

Scenario: Account has sufficient fund
        Given the account balance is $100
          And the Card is valid
          And the machine contains enough money
        When the account holder requests $20
        Then the ATM should dispense $20
          And the account balance should be $80
          And the card should be returned

.Story: Account holder withdraws cash
        As an Account Holder
        I want to withdraw cash from an ATM
        So that I can get money when the bank is closed

Scenario: Card has been disabled
        Given the Card is disabled
        When the Account Holder requests 20
        Then Card is retained
          And the ATM should say the Card has been retained

.Story: Tic tac toe
        As a player
        I want to have a tic tac toe game
        So that I can waste some time!

Scenario: Cat's game
        Given the board rows looks like [X, O, X], [O, O, X] and [X, X, O]
        Then it should be a cats game

.Story: Tic tac toe
        As a player
        I want to have a tic tac toe game
        So that I can waste some time!

Scenario: O wins
        Given the following board X, X, O, X, O,  ,  ,  ,
        When the game is played at (2, 0)
        Then the winner should be O

.Story: Tic tac toe
        As a player
        I want to have a tic tac toe game
        So that I can waste some time!

Scenario: When x and o play their first moves
        Given a new game
        When X and O play on (0, 0), (2, 2)
        Then the board state should be X,  ,  ,  ,  ,  ,  ,  , O

.N.Story: Tic tac toe
        As a player
        I want to have a tic tac toe game
        So that I can waste some time!

Scenario: X wins
        Given the board rows looks like [X, X, O], [X, X, O] and [O, O,  ]
        When x plays in the bottom right
        Then the winner should be x


Tests run: 7, Failures: 0, Not run: 1, Time: 0.775 seconds

 

Introduction to bddify: A Simple to Use and Extend BDD Framework for .NET

posted @ 2013-08-01 22:32 张善友 阅读(...) 评论(...) 编辑 收藏