2

Has anyone used Specflow with ApprovalTests?

I find it limiting that you can only approve one file per NUnit test and therefore each scenario can only have one approved file. This is the case even if you use scenario outlines.

This means I usually have to concatenate files and approve one large file which repesents the results of lots of independent tests.

I wonder has anyone found a better way?

LosManos
  • 7,195
  • 6
  • 56
  • 107
Martin Capodici
  • 1,486
  • 23
  • 27

1 Answers1

5

I'm the creator of approvaltests. I haven't used specflow myself yet, but the solution you are looking for would reside in the Namer.

A little background: Approve() uses 3 pieces

  1. a namer - this gets the .. received & approved file
  2. a writer - this outputs to that said file
  3. a reporter - this is called on failure

Right now the namers only use the class & method name to determine the file name which is why they cause a problem when you want more than one file per method.

you need to extend the namer to use more inputs (i'm guessing here but) class, method & scenario.

I'd be happy to pair w/you via skype to create the namer.

  • Yes that would be cool I am mcapodici on skype. I am on now for an hour or so. In general I am on from about EST 7pm - 1am. – Martin Capodici Oct 17 '11 at 04:46
  • I ran into the same problem trying to use BDDfy, or even before that with plain old unit tests. I would like to be able to have each call to Verify be unique. I just saw another post about using the NamerFactory to accomplish that, so I may play around with it. – Wade Hatler May 22 '14 at 18:39
  • @MartinCapodici did you came up with something? – David Walser Apr 22 '20 at 09:38
  • 1
    @DavidWalser whoa! That was almost 9 years ago. IIRC Llewellyn did commit something, maybe grep the git log for Oct 11 from https://github.com/approvals/ApprovalTests.Net/commits/master :-) – Martin Capodici Apr 23 '20 at 02:41