This project is read-only.

Multi line arguments

Apr 3, 2012 at 2:45 PM
Edited Apr 3, 2012 at 2:46 PM

Does nbehave support multi-line arguments?

like this (covered by three quotation marks """):

Given a blog post named "Random" with Markdown body
  """
  Some Title, Eh?
  ==============
  Here is the first paragraph of my blog post. Lorem ipsum dolor sit amet,
  consectetur adipiscing elit.
  """

I found that even docString ignored in GherkinListener.cs:

public void docString(string str, int line)        { }

Is it possible add support for multi-line step arguments? Or point to me how I can modify docString method?

P.S. I already looked at "Game Of life" example, however it does not works.

Feature: Game of life
Scenario: Empty game
Given a new game: 5 by 5Then the grid should be
.....
.....
.....
.....
.....

output:
NBehave version 0.6.0.0Copyright c NBehave 2007-2011All Rights Reserved.
Runtime Environment -   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1  CLR Version: 4.0.30319.239

Scenarios run: 0, Failures: 0, Pending: 0Steps 0, failed 0, pending 0System.ArgumentOutOfRangeException: Length cannot be less than zero.Parameter name: length
Server stack trace:  
 at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)   at NBehave.Narrator.Framework.ActionStepConverterExtensions.AsRegex(String actionStep)   at NBehave.Narrator.Framework.ActionStepAttribute..ctor(String regexOrTokenString)   at NBehave.Narrator.Framework.ThenAttribute..ctor(String regexOrTokenString)   at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)   at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)   at NBehave.Narrator.Framework.ActionStepParser.<GetAllMethodsWithActionStepAttribute>b__f(MethodInfo method)   at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()   at NBehave.Narrator.Framework.ActionStepParser.GetAllMethodsWithActionStepAttribute(IEnumerable`1 methodsWithActionStepAttribute)   at NBehave.Narrator.Framework.ActionStepParser.GetMethodsWithActionStepAttribute(Type actionSteps)   at NBehave.Narrator.Framework.ActionStepParser.FindActionStepMethods(Type actionSteps, Object instance)   at NBehave.Narrator.Framework.ActionStepParser.FindActionStepMethods(Type actionSteps)   at NBehave.Narrator.Framework.ActionStepParser.FindActionSteps(Assembly assembly)   at NBehave.Narrator.Framework.Contracts.LoadActionSteps.Initialise()   at NBehave.Narrator.Framework.Contracts.LoadActionSteps.<.ctor>b__0(RunStartedEvent started)   at NBehave.Narrator.Framework.Tiny.TinyMessengerHub.StrongTinyMessageSubscription`1.Deliver(ITinyMessage message)   at NBehave.Narrator.Framework.Tiny.DefaultTinyMessageProxy.Deliver(ITinyMessage message, ITinyMessageSubscription subscription)   at NBehave.Narrator.Framework.Tiny.TinyMessengerHub.<>c__DisplayClass11`1.<PublishInternal>b__f(SubscriptionItem sub)   at System.Collections.Generic.List`1.ForEach(Action`1 action)   at NBehave.Narrator.Framework.Tiny.TinyMessengerHub.PublishInternal[TMessage](TMessage message)   at NBehave.Narrator.Framework.Tiny.TinyMessengerHub.Publish[TMessage](TMessage message)   at NBehave.Narrator.Framework.TextRunner.Run()   at NBehave.Narrator.Framework.Remoting.RemotableStoryRunner.Run()   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)   at NBehave.Narrator.Framework.IRunner.Run()   at NBehave.Narrator.Framework.Remoting.AppDomainRunner.Run()   at NBehave.Console.NBehaveConsoleRunner.Run(NBehaveConfiguration config)   at NBehave.Console.NBehaveConsoleRunner.Main(String[] args)Time Taken 0.7s
Apr 6, 2012 at 10:38 AM

The Game of Life example is broken because I have introduced a bug :-( I will fix it asap.

docstrings isn't implemented yet, if you want to help out with that you are very welcome. In what ways can I assist you to get started with that?
FYI, I am in the middle of a rather big refactoring of the codebase so I would hold it off until that refactoring is committed (which should be done this weekend).

Apr 6, 2012 at 9:02 PM

I have fixed the issues with the Game Of Life example in build 287

Apr 26, 2012 at 4:28 PM

Hi LazyDev,

  Thanks a lot. passing multi-line parameters works with build 287. 

  So now I don't know is it worth implement docStrings? :)  Because simple regexp (?<rows>(.+\s*)+)") works like a charm.

 

Apr 27, 2012 at 8:57 AM

Well, maybe its not worth implementing docStrings, but I did it anyway :-)

Its in the repo, but it doesnt handle the indentation correctly.